![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing duplicates in a sorted file by field. | kinksville | Shell Programming and Scripting | 1 | 04-29-2008 02:03 PM |
| Remove duplicates from File from specific location | gopikgunda | Shell Programming and Scripting | 1 | 04-09-2008 02:16 AM |
| removing duplicates from a file | trichyselva | UNIX for Dummies Questions & Answers | 2 | 03-25-2008 10:49 AM |
| Avoid creating temporary files on editing a file in Ubuntu | royalibrahim | Ubuntu | 7 | 11-17-2007 05:57 AM |
| Reading Input from File and Duplicates Output | noelcantona | Shell Programming and Scripting | 6 | 10-18-2005 04:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Avoid Duplicates in a file
Hi Gurus,
I had a question regarding avoiding duplicates.i have a file abc.txt abc.txt ------- READER_1_1_1> HIER_28056 XML Reader: Error [UnterminatedXMLDecl] occurred while parsing:[Error at (file /home/abc.xml, line 6, char 1 ): Invalid document structure.]; line number [6]; column number [1] READER_1_3_1> Sun Mar 23 23:52:48 2008 READER_1_3_1> HIER_28056 XML Reader: Error [UnterminatedXMLDecl] occurred while parsing:[Error at (file /home/abc.xml, line 6, char 1 ): Invalid document structure.]; line number [6]; column number [1] READER_1_2_1> Sun Mar 23 23:52:48 2008 READER_1_2_1> HIER_28056 XML Reader: Error [UnterminatedXMLDecl] occurred while parsing:[Error at (file /home/abc.xml, line 6, char 1 ): Invalid document structure.]; line number [6]; column number [1] READER_1_1_1> Sun Mar 23 23:52:48 2008 READER_1_1_1> HIER_28058 XML Reader Error READER_1_2_1> Sun Mar 23 23:52:48 2008 READER_1_2_1> HIER_28058 XML Reader Error READER_1_3_1> Sun Mar 23 23:52:48 2008 READER_1_3_1> HIER_28058 XML Reader Error. I will get this file when i egrep the session log file for error specific messages. here i want to remove the repeated lines in this file? i am try to use uniq command, but here READER_1_3_1> will be varying in the above abc.txt file i.e., in every line we have 1,2,3 in place of READER_1_**_1>. So i am not getting the desired output. Can any one let me know how to get the requirement done. My output should be READER_1_1_1> HIER_28056 XML Reader: Error [UnterminatedXMLDecl] occurred while parsing:[Error at (file /home/abc.xml, line 6, char 1 ): Invalid document structure.]; line number [6]; column number [1] READER_1_1_1> HIER_28058 XML Reader Error ![]() Thanks & Regards, San |
|
||||
|
My question is: Does every message have 2 duplicates in input data?
You gave abc.txt example, where every messages is duplicated with 'READER_1_2_1>' and 'READER_1_3_1>' headers added. If all logs are presented in such way you can: Code:
grep 'error message string' abc.txt | grep 'READER_1_1_1>' |
|
||||
|
Quote:
No since it reads from 3 sources it will be giving out 3 errors.But the source is same so i get 3 similar messages with only reader variation. Here in reader place i may get any other word . |
|
||||
|
All you need to trim a file down to unique lines is:
Code:
sort -u file ShawnMilo |
|
||||
|
Quote:
But here all the lines are unique since reader_1 will be changed Reader_2.only that variation will be there, so if i use uniq command it not getting the desired output. |
![]() |
| Bookmarks |
| Tags |
| awk, awk trim, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|