Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about awk 1

Status
Not open for further replies.

linuxMaestro

Instructor
Jan 12, 2004
183
US
I am trying to awk the first number.

line="51 requests currently being processed, 9 idle servers";
num=awk($line,\d*);
if ($num>200)
mail linux@maestro.com

what is the correct syntax for awk to grep the 51 from the line above?
 
#!/bin/ksh

line="51 requests currently being processed, 9 idle servers";
num=awk($line,\d*);
if [ $(echo "${line}" | awk '{print $1}) -gt 200 ]; then
mail linux@maestro.com
fi;

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
No awk needed at all:
line="51 requests currently being processed, 9 idle servers"
set -- $line
if [ $1 -gt 200 ]; then
mail linux@maestro.com
fi

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top