Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: one liner to print out sorted list of word (sort(1))

by Aristotle (Chancellor)
on Mar 30, 2003 at 20:26 UTC ( [id://246775]=note: print w/replies, xml ) Need Help??


in reply to one liner to print out sorted list of word

Why is everyone trying to reinvent the wheel?
sort -u file # case sensitive sort -fu file # insensitive
That takes care of lines. To change the interpretation of what a line is, use tr(1), f.ex
< file tr [:blank:] '\n' | sort -fu
Shell still excels at really simple things it has dedicated tools for. Perl beats it if you want to do something there's no exactly matching tool for.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: one liner to print out sorted list of word (sort(1))
by Anonymous Monk on Mar 30, 2003 at 21:27 UTC

    Isn't ShellMonks up the road somewhere?

Re: Re: one liner to print out sorted list of word (sort(1))
by maksl (Pilgrim) on Mar 30, 2003 at 21:06 UTC
    thx a lot Aristotle for your "_minimalistic_" reply :)
    update: second even shorter line with code from dakkar
    < file tr [:blank:],[:punct:] '\n' | sort -fu < file tr -cs '[:alnum:]' '\n'|sort -fu
    is exactly what i was looking for!!!
    never saw the file redirector < on the beginning of a shell command, i use it for things like:
    mail -s "test" person@what_ever.org < file

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://246775]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found