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 > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 05-13-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,301
Code:
awk 'NR==FNR{a[substr($0,1,5)];next}
Gets first 5 characters of the first file into array.

Code:
 NF<3{next}
Ignore lines with less then 3 fields (the first and last line)

Code:
 substr($1,2,5) in a {print > "file1";next}
If 5 characters after quotes in array print to file1..

Code:
 {print > "file2"}
... else print to file2


The original files should not change.

Regards

Last edited by Franklin52; 05-13-2008 at 01:03 PM.. Reason: linguistic correction