![]() |
|
|
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 |
| how to read record by record from a file in unix | raoscb | UNIX for Dummies Questions & Answers | 1 | 05-16-2008 07:30 AM |
| Remove First and Last Record from a file | ravikuc | UNIX for Dummies Questions & Answers | 1 | 10-11-2007 04:35 AM |
| splitting a record and adding a record to a file | rsolap | Shell Programming and Scripting | 1 | 08-13-2007 02:58 PM |
| command to remove last record on file | mheinen | UNIX for Dummies Questions & Answers | 4 | 01-09-2007 04:39 PM |
| remove duplicated xml record in a file under unix | happyv | Shell Programming and Scripting | 8 | 09-20-2006 02:36 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
file type: Code:
NMT000010000100001ENVL,CSP,28#,9X12,KFT,1C 00001 NA20000105500000003081547100100008000000000024.19 000000000000001DZ 000000000024.19 000000000000000 00002 NPD TOP63120 TOP63120 NP2 00000000000000 00000000000000 000 00000000000000 00000000000001 00000000000000 00000000000000 NMT000010000800001PAD,LGL RL,PRISM,LTR,BE |
|
||||
|
Code:
grep -vE '^(NPD|NA2)' file > file2 While it's trivial to do this in sed, if there's a way to remove newlines in sed, I've never found it. You could always try piping it into Perl: Code:
cat file | perl -ne 'print unless /^(NPD|NA2)/;' |
|
||||
|
Quote:
![]() Code:
$ cat file
NMT000010000100001ENVL,CSP,28#,9X12,KFT,1C 00001
NA20000105500000003081547100100008000000000024.19 000000000000001DZ 000000000024.19 000000000000000 00002
NPD TOP63120
TOP63120
NP2
00000000000000 00000000000000 000
00000000000000 00000000000001 00000000000000 00000000000000
NMT000010000800001PAD,LGL RL,PRISM,LTR,BE
$ grep -v '^NA2\|^NPD' file > new_file
$ cat new_file
NMT000010000100001ENVL,CSP,28#,9X12,KFT,1C 00001
TOP63120
NP2
00000000000000 00000000000000 000
00000000000000 00000000000001 00000000000000 00000000000000
NMT000010000800001PAD,LGL RL,PRISM,LTR,BE
$ wc -l file
8 file
$ wc -l new_file
6 new_file
Or sed Code:
$ sed '/^NA2/d;/^NPD/d;' file > new_file2
$ wc -l new_file2
6 new_file2
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|