LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-20-2008, 01:41 AM   #1
hinetvenkat
Member
 
Registered: Nov 2004
Location: Mumbai
Posts: 80

Rep: Reputation: 15
the number of occurrences of the word in file


Hi

How to find the number of occurrences of the word in a file. want only in linux bash ( using grep/sed/awk/find/etc )

Thanks
 
Old 02-20-2008, 06:25 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
grep -o word filename|wc -w

This will find all instances of "word", even if embedded in a larger word. For something more specific, you'll need a regular expression in the place of "word".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to count occurrences of unique words in a file beeblequix Linux - General 8 06-05-2018 10:16 AM
how to delete last number/word of a file and incude file count at the end of the chennaiguy Linux - Newbie 2 02-18-2008 09:08 PM
[SOLVED] find a word in a file, and change a word beneath it ?? vikas027 Programming 10 02-14-2008 09:46 PM
how to count the number of occurrences of a process beeblequix Linux - General 3 09-18-2006 04:17 PM
help on finding the number that has max occurrences in a column [sql query] zeppelin Programming 6 06-15-2004 01:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration