Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting files while ignoring duplicates

Status
Not open for further replies.

bluebonnet

Technical User
Feb 26, 2003
10
US
I want to sort a file(pudding) by the 1st column
but ignore all of the duplicates and output
the results to another file (prices).
For example,

sort +1 pudding > prices

the file looks like this..

Pudding Price

1 vanilla 1.05
2 strawberry 1.05
etc...

 
Oops! I need to add the word uniq to this equation.
 
Actually, if you want them sorted numerically, it should be...
[tt]
sort -n pudding | uniq > prices
[/tt]
Without the [tt]-n[/tt], they sort like...
[tt]
1 vanilla 1.05
10 peach 1.05
2 strawberry 1.05
20 chocolate 1.05
[/tt]
Whereas WITH the [tt]-n[/tt], they sort...
[tt]
1 vanilla 1.05
2 strawberry 1.05
10 peach 1.05
20 chocolate 1.05
[/tt]
Hope this helps.

 
I meant the sort it by the pudding column only.
Code is different. How would it look?
 
It would be +1.
would I printed out only the pudding section
and redirected it to another file?
How would that command look??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top