Computing.Net > Forums > Unix > Shell variable in AWK

Shell variable in AWK

Reply to Message Icon

Original Message
Name: dk0871
Date: December 23, 2004 at 13:45:58 Pacific
Subject: Shell variable in AWK
OS: Sun OS 5.6
CPU/Ram: Not Known
Comment:

I need some help of how to use shell variable in awk '{action}' section? Tried several way doesn't seem to be get it right.

Thanks in advance.


dkr


Report Offensive Message For Removal


Response Number 1
Name: Borvix
Date: December 24, 2004 at 08:41:33 Pacific
Subject: Shell variable in AWK
Reply: (edit)

It is subject to whole lesson ”how”, but I think you may find this link to be useful.
http://www.vectorsite.net/tsawk.html


Learn more at www.TechnoProfessor.com


Report Offensive Follow Up For Removal

Response Number 2
Name: nails
Date: December 29, 2004 at 07:53:10 Pacific
Subject: Shell variable in AWK
Reply: (edit)

I prefer to pass shell variables to an awk script, but this little stub embedds one:


VAR=5
echo "test" |awk '{ print "'"$VAR"'" }'

Regards,

Nails


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Shell variable in AWK

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge