Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-03-2012
Registered User
 
Join Date: Oct 2011
Location: Hyderabad, Bharath
Posts: 58
Thanks: 3
Thanked 1 Time in 1 Post
Number of word occurences in a file?

Hello world,
Can anybody tell me how to count how many times does a word repeat in a file? There have been many threads on this but they all are heavy loads of Scripting for a starter like me.
So, I sat down today and after some hours of reading man pages, I found a simple one-line execution. But, I cannot paste this in any threads as they are all closed!
(Can the forum staff please let me know why threads are closed?? I really don't know).

Your buddy,
Satheesh

---------- Post updated at 09:17 AM ---------- Previous update was at 09:15 AM ----------

The reason I started this thread is either someone newbie benefits or I can be corrected if I went wrong somewhere.
Sponsored Links
    #2  
Old 03-03-2012
balajesuri's Avatar
#! /bin/bash
 
Join Date: Apr 2009
Location: India
Posts: 1,561
Thanks: 14
Thanked 438 Times in 423 Posts

Code:
perl -lne '$i++ while(/\bWORD\b/g);END{print $i}' inputfile

Sponsored Links
    #3  
Old 03-03-2012
Scott's Avatar
Scott Scott is online now Forum Staff  
Administrator
 
Join Date: Jun 2009
Location: Zürich
Posts: 6,880
Thanks: 212
Thanked 745 Times in 651 Posts
@satish51392111

You can post it here

Threads are automatically closed, if not posted in, after a period of time (I think 6 months, but can't find the discussion thread we had on the subject )
    #4  
Old 03-03-2012
Registered User
 
Join Date: Oct 2011
Location: Hyderabad, Bharath
Posts: 58
Thanks: 3
Thanked 1 Time in 1 Post
I'm very much new to *nix and so I posted it in this Forum-for-dummies. So, no scripting please. These one line scripts are in all the threads I went through earlier.

Also, why are the threads closed?
Sponsored Links
    #5  
Old 03-03-2012
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Location: Asia pacific region
Posts: 11,514
Thanks: 308
Thanked 617 Times in 256 Posts
Quote:
Originally Posted by satish51392111 View Post
I'm very much new to *nix and so I posted it in this Forum-for-dummies. So, no scripting please. These one line scripts are in all the threads I went through earlier.

Also, why are the threads closed?
We close inactive threads because they are inactive.

If you want to start a new thread on a similar subject, you can put a link to the old, closed thread.

You really should be asking these questions in the support forum, not in the technical areas.
Sponsored Links
    #6  
Old 03-03-2012
Registered User
 
Join Date: Oct 2011
Location: Hyderabad, Bharath
Posts: 58
Thanks: 3
Thanked 1 Time in 1 Post
Ok, got it. I'll next time.
Back to my question please.. any simple suggestions?
Sponsored Links
    #7  
Old 03-03-2012
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Location: Asia pacific region
Posts: 11,514
Thanks: 308
Thanked 617 Times in 256 Posts
Quote:
Originally Posted by satish51392111 View Post
I cannot paste this in any threads as they are closed ....
Nonsense... you can cut and paste from any thread, closed or not.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk counting number of occurences phamp008 Shell Programming and Scripting 3 09-19-2009 12:52 PM
Count number of occurences of a word shikhakaul UNIX for Dummies Questions & Answers 8 06-25-2009 11:10 AM
How to count the occurences of a specific word in a file in bash shell mskart UNIX for Dummies Questions & Answers 2 10-30-2008 12:42 PM
no of occurences of q word Satyak Shell Programming and Scripting 6 09-29-2008 02:38 AM
How to find all occurences of word? vanitham Web Programming 0 09-06-2008 05:35 AM



All times are GMT -4. The time now is 04:01 AM.