The UNIX and Linux Forums  

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 -->
  #6 (permalink)  
Old 03-18-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
a more generic solution:

nawk -v str='foo1 foo2 foo3' -v pos='266 288' -f hugo.awk myFile

hugo.awk:

Code:
BEGIN {
   split(str, strA, FS)
   split(pos, posA, FS)
}
{
   for(strI=1; strI in strA; strI++)
      for(posI=1; posI in posA; posI++)
        if ( posA[posI] == match($0, strA[strI]) ) {
           print
           next
        }
}


Last edited by vgersh99; 03-18-2009 at 12:13 PM..