Hello,
I am writing a shell script and I need to find a way to
count the number of whitespaces in a string.
Eg:
NAME="Bob Hope"
I am looking for a way to count the number of whitespaces in this string. So a command that would take this string and return 1.
Or take
"First Middle Last" and return 2.
I know this could be achieved using an array to store the NAME and then searching through each element of the array and count the number of whitespaces. But I was hoping that there would be a simplier way.
Thank You