More
Forums
Blog
Photos
Members
Videos
Contact
Calendar
TECH SOLUTIONS
Click here to edit subtitle
Forums
Post Reply
Forum Home
>
Unix Learnings
>
Awk script to count number of occurences of a word in the file
Sourav Gulati
Site Owner
Posts: 83
$awk 'BEGIN{num=0}{for(i=0;i<NF;i++){if($i=="word") num++;}}END{print num;}' file.txt
--
November 21, 2012 at 3:40 AM
Flag
Quote & Reply
You must
login
to post.