I want to count number of words from a String using Shell.
Suppose the String is:
input="Count from this String"
Here the delimiter is space ' '
and expected output is 4.
There can also be trailing space characters in the input string like "Count from this String "
.
If there are trailing space in the String, it should produce the same output, that is 4. How can I do this?