Need help in word count command
Hi,
I have a file(text.txt) and it something like this: Book and Book book I don't know what to write here Book I need to know what Book Ok, when do word count it should say the word 'book' appear 5 times. I try this command but no luck...!! grep -i book text.txt |wc -w <--- result 10 cat text.txt | grep -i book |wc -w <--- result 10 cat text.txt | grep -i book |wc -l <--- result 3 grep -c book text.txt <--- result 1 Anyone can help? Thanks. |
1 - number of words in all the lines which contain the word "book"
2 - same as 1 3 - number of lines containing the word "book" 4 - number of lines containing the word "book", case sensitive. |
Code:
grep -o book <file> | wc -l |
Or perhaps more simply "grep -oi book file | wc -l"
|
Thanks all..
"grep -oi book file | wc -l" working just great!!! |
All times are GMT -5. The time now is 12:27 PM. |