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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

substr() causing false result 1

Status
Not open for further replies.

nabana2

Technical User
Sep 26, 2005
21
ZA
Hi

Please could someone explaing the difference between a and b in the script below.

Not sure why the "a" test gives a false result.

echo 19G 19 | awk '{
alert= 5
a= substr($1,1,length($1)-1)
b= $2

if(a <= alert){
print "a: "a" is not less than "alert
}
if(b <= alert){
print "b: "b" is not less than "alert
}
}'

Thank you
 
substr return a string.
Try this:
a=substr($1,1,length($1)-1)[!]+0[/!]

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

Part and Inventory Search

Sponsor

Back
Top