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 -->
  #2 (permalink)  
Old 07-17-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink A different approach (albeit untested)

Code:
while read zf
   do
   prod=$(echo "$zf" | cut -d"|" -f2)
   valid_prod=$(echo "$products" | grep "$prod")
   if [ -n "$valid_prod" ]
      then
      echo "$zf" >>$new_file
   fi
done <$filename
Sometimes I get so confused using the ' and ` thus I prefer the above approach.