The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-08-2006
Registered User
 

Join Date: Apr 2006
Posts: 11
question about wc

Hey my friend was asking me if i knew a way to cout how many different words in a file. I told him no not off hand, but i was thinking about it, and i started to wonder also. I imagine this is probably pretty simple im just missing something, I keep confusing my self with how you would compair and filter out the same words twice or more. If any one knows of a way to do this id like to know.....

thanks
Reply With Quote
Forum Sponsor
  #2  
Old 05-08-2006
Registered User
 

Join Date: Dec 2005
Location: India
Posts: 218
may sound weird but give it a try,

1) get all the words in a single column. example say your file is

a b df sd ff d

make it
a
b
df
sd
ff
.
.


2) sort the output of step 1
3) use uniq command on the output of step2
Reply With Quote
  #3  
Old 05-08-2006
Registered User
 

Join Date: Apr 2006
Posts: 11
oh i see, i didnt know about the uniq command, thanks a lot!
Reply With Quote
  #4  
Old 05-08-2006
Registered User
 

Join Date: Dec 2005
Location: India
Posts: 218
post back if you get something, would like to see if it really works out.
theoretically it should work fine
Reply With Quote
  #5  
Old 05-08-2006
mrn mrn is offline
Registered User
 

Join Date: May 2006
Posts: 3
sort -u filename|wc
Reply With Quote
  #6  
Old 05-08-2006
Registered User
 

Join Date: Dec 2005
Location: India
Posts: 218
Quote:
Originally Posted by mrn
sort -u filename|wc
dont thinks this will work
Reply With Quote
  #7  
Old 05-08-2006
mrn mrn is offline
Registered User
 

Join Date: May 2006
Posts: 3
Works on AIX / Solaris / HP & Redhat
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0