![]() |
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 |
| 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 |
| SED: how to remove newline after pattern? | nico.ben | Shell Programming and Scripting | 1 | 01-02-2009 10:59 PM |
| sed/awk help to match list of patterns and remove from org file | rajan_san | Shell Programming and Scripting | 1 | 12-07-2008 02:56 AM |
| Delete lines between two patterns without deleting the second pattern | Ilja | Shell Programming and Scripting | 1 | 11-14-2008 09:53 AM |
| comment/delete a particular pattern starting from second line of the matching pattern | imas | Shell Programming and Scripting | 4 | 10-13-2008 02:37 AM |
| sed remove everything up to the pattern | katrvu | Shell Programming and Scripting | 4 | 04-08-2008 09:35 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
delete two patterns and remove one pattern
Friends,
I have .txt file with following format. START ABC|Prashant1|Patel1 ABC|Prashant2|Patel2 ABC|Prashant1|Patel1 ABC|Prashant2|Patel2 END I would like to do: 1) Delete line with START 2) Delete line with END 3) Remove ABC| 4) Delete duplicate records The following command works fine which deletes line with START and END sed -e /^START/d -e /^END/d Filename.txt How do I incorporate task 3 and 4? NOTE: The file will have more than 500,000 thousand rows. Thanks in advance for suggestion, Prashant |
|
||||
|
Quote:
Code:
nawk -F'|' 'NF==3{print $2,$3}' patel
|
|
||||
|
Quote:
Tostay2003: What if the data doesnt start with ABC your logic fails use this nawk -F'|' 'NF==3{print $2,$3}' patel | sort -u |
|
||||
|
Quote:
Quote:
Code:
grep "|" test | cut -d'|' -f2,3 | sort -u |
|
||||
|
Thank you all for your reply.
Code:
nawk -F'|' 'NF==3 && !a[$2,$3]++ {print $2,$3}' patel
Code:
nawk -F'|' 'NF==3 && !a[$2,$3]++ {print $2,"|",$3}' patel
Thanks, Prashant |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|