![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
oh i see, i didnt know about the uniq command, thanks a lot!
|
|
#4
|
|||
|
|||
|
post back if you get something, would like to see if it really works out.
theoretically it should work fine |
|
#5
|
|||
|
|||
|
sort -u filename|wc
|
|
#6
|
|||
|
|||
|
Quote:
|
|
#7
|
|||
|
|||
|
Works on AIX / Solaris / HP & Redhat
|
|||
| Google The UNIX and Linux Forums |