Computing.Net > Forums > Programming > Shell Script with AWK

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell Script with AWK

Reply to Message Icon

Name: charlyrosario
Date: June 21, 2007 at 07:27:03 Pacific
OS: unix
CPU/Ram: 2 G
Product: HP
Comment:

I am working with Shell Script in awk and i need to use an external variable inside awk chain as follows:
PhysMem=´prtconf | grep Memory | awk ' {print $3}'´
MEM=´tail -1 /tmp/.sar | awk ' $2 = int(100-($2 * 100 / $PhysMem)) {print $2}'´

How can i do it?

Charlyrosario



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: June 21, 2007 at 13:36:59 Pacific
Reply:

awk -v var=$PhysMem '{ print var }'


0

Response Number 2
Name: nails
Date: June 22, 2007 at 09:28:17 Pacific
Reply:

There is more than one way to use shell variables in awk. Check out this link:

http://www.tek-tips.com/faqs.cfm?fi...


0

Response Number 3
Name: charlyrosario
Date: June 22, 2007 at 14:31:34 Pacific
Reply:

Thanks a lot to both nails and ghostdog

Charlyrosario


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Shell Script with AWK

running shell script on XP www.computing.net/answers/programming/running-shell-script-on-xp/14232.html

how to write shell script www.computing.net/answers/programming/how-to-write-shell-script/6692.html

Shell commnd in awk script www.computing.net/answers/programming/shell-commnd-in-awk-script/13781.html