The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #8 (permalink)  
Old 07-22-2008
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,421
Quote:
Originally Posted by kanu_pathak View Post
grep is not doing anything. new_file is still with the same records.
Work's for me
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