![]() |
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 |
| using AWK see the upper lines and lower lines of the strings?? | thepurple | Shell Programming and Scripting | 3 | 10-07-2008 10:24 AM |
| list and export strings in a file | Avatar Gixxer | Shell Programming and Scripting | 3 | 09-19-2008 06:41 AM |
| Perl RegExp to remove last character from strings | ospreyeagle | Shell Programming and Scripting | 2 | 04-03-2008 02:55 PM |
| matching characters between strings | akmtcs | UNIX for Dummies Questions & Answers | 9 | 12-08-2006 09:04 AM |
| Remove Carriage returns between strings in a field | acheepi | Shell Programming and Scripting | 10 | 09-24-2005 01:19 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
HP-UX gxxxxxxxc B.11.23 U ia64 3717505098 unlimited-user license I have a file with below pipe separated field values: xxx|xxx|abcd|xxx|xxx|xx xxx|xxx|abcd#123|xxx|xxx|xx xxx|xxx|abcd#345|xxx|xxx|xx xxx|xxx|pqrs|xxx|xxx|xx xxx|xxx|pqrs#123|xxx|xxx|xx The third field has values like abcd and pqrs. I need a file with lines only with abcd and pqrs. The other lines that have abcd#123, abcd#345 should be removed. Same for pqrs field also. This is a huge file and many in numbers. So, I need some expert suggestion to have an efficient solution. I have used awk -F"|" '{print $3}' | grep -v "#". It only gives me abcd and pqrs. I need the corresponding lines in a separate file. My output file should be: xxx|xxx|abcd|xxx|xxx|xx xxx|xxx|pqrs|xxx|xxx|xx I have a great respect to the knowledgeable participants and their willingness to help in this forum and also I have taken a lot of help in finding my answers in the past from you guys. I know I can't be let down. Please help, it is important for me to remain as a developer. Thanks in advance. Manjax |
|
||||
|
Hi,
I should mention that the strings may be anything. abcd and pqrs were just examples. All I know is that there is a third field string with and without #. I need lines without #. Hope we are on the same page. Thanks for the quick come back. Manjax |
|
|||||
|
Code:
grep '^[^|]*\|[^|]*\|[^#|]*\|' infile>outfile Code:
egrep '^([^|]*\|){2}[^#|]*\|' infile>outfile
Last edited by radoulov; 10-16-2008 at 03:59 AM.. Reason: corrected |
![]() |
| Bookmarks |
| Tags |
| lines, list of strings, remove, strings list |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|