I am trying to get the word count of a string using the
wc command. But it gives me a different answer. It increases the number of words by 1.
This is the code:
echo Enter a string: read str len=`echo $str | wc -c` echo you have entered: $str echo and the word count: $len
The output is like this:
Enter a string: robin you have entered: robin and word count: 6
What am I doing wrong? Please help me solve this. I will be very grateful. Thank you.