Count Words

Count the number of whitespace-separated words in a string.

Code

General
echo "$str" | wc -w | tr -d ' '

Parameters

The string to count words in

Server

More Bash Snippets