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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…