word count of each line in linux

April 13, 2011 at 19:20:38
Specs: Windows XP
how to get the word count of each line in linux

See More: word count of each line in linux

Report •

#1
April 13, 2011 at 23:03:53
look at the wc command namely the -c option:

man wc


Report •

#2
April 14, 2011 at 00:32:00
wrong option: WORD count, not BYTES count
but the man page will clarify that

Report •

#3
April 14, 2011 at 05:56:47
wc gives the count of all words in a file
but what 2 do for getting no. of words in each line separate

Report •

Related Solutions

#4
April 14, 2011 at 10:49:18
Read each line and echo that line to the wc command:


# UNTESTED
while read line
do
cnt=$(echo "$line"|wc -w)
done < file


Report •

Ask Question