Taking text output of any command and manipulating it with a while read loop
by Rich Ungsunan

output | while read line; do  $line; done;
eg. adding a timestamp to a tailed file:
tail -f filename | while read line; do echo `date` $line; done 
The output of the command is considered the variable "line" which could be called with $line for anything afterwards, e. g. grabbing a particular (3rd) column of output:
cat filename | while read line; do awk '{print $3}' ; done 
You can pipe that output to anything like sort followed by uniq -c to get a count of the words in that column.

Copyright by techTips