![]() |
|
|
|
|
|||||||
| 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. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing the first and last lines in a file | naveendronavall | Shell Programming and Scripting | 2 | 12-29-2007 10:22 PM |
| Removing the first and last lines in a file | naveendronavall | AIX | 1 | 12-29-2007 08:44 PM |
| Removing lines from a file | computersaysno | UNIX for Dummies Questions & Answers | 6 | 11-14-2006 03:50 PM |
| Removing lines within a file | tookers | Shell Programming and Scripting | 3 | 08-22-2006 06:49 AM |
| Removing lines from a file | PradeepRed | Shell Programming and Scripting | 4 | 12-17-2005 03:34 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Removing dupicate lines in the file ..(they are not continuous)
I have duplicates records in a file, but they are not consecutive. I want to remove the duplicates , using script.
Can some one help me in writing a ksh script to implement this task. Ex file is like below. 1234 5689 4556 1234 4444 5555 6889 5689 7898 1234 from the above file i want to get rid of duplicates of 1234 and 5689 thanks srini |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
awk '!x[$0]++' file.old >file.new Code:
sort -u -o file.new file.old |
|
#3
|
||||
|
||||
|
Code:
nawk '!a[$0]' file.txt |
|
#4
|
|||
|
|||
|
to eliminate all the duplicates
Code:
sort <filename> | uniq -u Code:
sort <filename> | uniq Last edited by matrixmadhan; 09-29-2005 at 07:04 AM. Reason: reread the problem |
|
#5
|
|||
|
|||
|
It works fine , but
Thank you everyone, it works fine ,
But I have some other problem now , The result file is coming as Sep 28 11:09:33> Error on trans: 2 Sep 28 12:10:42> Error on trans: 1 Sep 28 12:10:43> Error on trans: 1 Sep 28 12:14:43> Error on trans: 1 Sep 28 12:14:44> Error on trans: 1 I want the output to be as follows Sep 28 11:09:33> Error on trans: 2 Sep 28 12:10:42> Error on trans: 1 Can some one help me in doing this too. thanks Srinii |
|
#6
|
||||
|
||||
|
Code:
nawk '!a[$NF]++' file.txt |
|
#7
|
|||
|
|||
|
Thanks, It works ..
hi vgersh99,
Thanks for your help, Can you please explan me what actually is happening when we execute the above command ?? i.e nawk '!a[$NF]++' file.txt Thanks Srini |
|||
| Google The UNIX and Linux Forums |