The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove Similar Lines from a File Nysif Steve Shell Programming and Scripting 4 03-13-2009 03:49 AM
How to get/print the lines from a specified file ? (LINUX) rajavu UNIX for Dummies Questions & Answers 4 12-23-2008 04:47 PM
Need to print certain lines from a file jack00423 Shell Programming and Scripting 25 09-29-2008 10:03 PM
print all even lines of a txt file ajp7701 Shell Programming and Scripting 1 04-17-2008 11:17 PM
Print only certain lines from a text file CamTu Shell Programming and Scripting 1 06-01-2005 11:47 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-27-2009
shira's Avatar
shira shira is offline
Registered User
  
 

Join Date: Jan 2009
Location: Israel
Posts: 35
How to sort a file and then print similar lines once

Hi!

I have a trouble with the sort and the uniq.
I know I have to use them, I just have trouble with putting them in the right order.

I have a text file with unsorted lines (each line has a few words, the first word in the line is a number.).

I need to sort this file in order to be able to use the uniq command.

I tried to write it like this:

Code:
 
sort -n file | uniq
(I wrote the -n option because the first string in each line is a number. Is it okay?)

but when I cat the file it's not changed, and furthermore, the output is doubling a few lines not necessarily.

What is wrong?

Thanks,
Shira.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0