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 -->
  #1 (permalink)  
Old 05-01-2007
Ant1815 Ant1815 is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 9
Passing a for loop variable into nawk

After searching through books and the internet for days I can't seem to find an example of this.

I'm trying to pass a variable from a for loop into nawk but can't seem to get all the syntax right.

my script (thanks to anbu23 for nawk help) is this:

for customers in `cat customers.txt`
do
nawk '$8 == "${customers}"' custom.txt > output/$customers.txt
done

I know that the 'output/$customers.txt' works, so it is being recognised, but the "${customers}" isn't being recognised. I've tried all manner of brackets and quotes in different places but can't seem to get nawk to recognise the variable in this particular place.

Thanks for any help.