Find Longest Word

Find the longest word in a string.

Code

General
echo "$str" | tr ' ' '\n' | awk '{ print length, $0 }' | sort -rn | head -1 | cut -d' ' -f2

Parameters

The string to search

Server

More Bash Snippets