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!

Convert a string to an integer

Status
Not open for further replies.

cdeardor

MIS
Oct 25, 2002
49
US
I'm trying to compare 2 values in my script. Problem is, one is a string and the other is an integer. Can anyone give me an example of how you would convert a string to an integer on linux inside a shell script?
 
typeset -i intVar=$strVar

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Perfect. It didn't seem to like decimals, but that wasn't a hard to work around. Thank you!
 
If you want decimal values you have to play with bc

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