the problem is the comparison, i've tried -gt and >, however when i use -gt it comes up with the error, and when i use > it goes into the if statement regardless of it being smaller in the comparison,
is there any way to compare the output (0.4) to make sure it only goes into the if statement when greater than 40,
Your problem is that the bourne shell, sh, and the '88 version of korn shell does not do decimal type arithmetic. The bc command, arbitrary precision command, is one way of solving this problem.
Go to this link for a bc example using an if statement:
you can do everything in awk, no need for bc [code] #!/bin/sh /usr/bin/prstat -p 13633 1 1 | nawk ' NR == 2 { sub("%", "",$9) print $9 if ($9 <= 40) { print "lower" } else if ( $9 > 40 ) { print "higher" } }' [/code]
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE