![]() |
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 |
| modify a particular pattern starting from second line of the search pattern | imas | UNIX for Dummies Questions & Answers | 2 | 10-12-2008 11:30 AM |
| Search for a pattern in part of the line | pineapples | Shell Programming and Scripting | 6 | 09-10-2008 10:42 AM |
| search for the matched pattern by tracing back from the line | Sharmila_P | Shell Programming and Scripting | 9 | 08-04-2008 08:21 AM |
| Multile Pattern Search in a same line and delete | sasree76 | Shell Programming and Scripting | 2 | 04-16-2008 02:12 PM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 03:41 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
modify a particular pattern starting from second line of the search pattern
Hi,
I think you ppl did not get my question correctly, let me explain I have 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 0789456|332211|10.20.30.40|078945633 1234567|225522|10.20.30.50|123456733 0321654|999999|10.20.30.40|032165433 0456123|777899|10.20.30.40|045612333 *** *** *** I want take the IP Address column from 1.txt and then search it in 2.txt and comment the duplicate entry from second matched pattern. i.e., i need to have the following output in 2.txt as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 #0789456|332211|10.20.30.40|078945633 #1234567|225522|10.20.30.50|123456733 #0321654|999999|10.20.30.40|032165433 #0456123|777899|10.20.30.40|045612333 *** *** *** Below is the script i wrote but it will comment all the duplicate entries: for i in `cat 1.txt |cut -d"|" -f3` do cat 2.txt |sed "s/^\(.*\|$i\|.*)/#/g" > tmp.txt mv tmp.txt 2.txt done Can some one guide me how to leave the first duplicate entry untouched and comment from second duplicate entry and so on. Please do not close this thread if you do not know the answer. Thanks -Imas |
|
||||
|
No duplicate or cross-posting, read the rules.
Proceed here: comment/delete a particular pattern starting from second line of the matching pattern Thread closed. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|