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 string to integer 1

Status
Not open for further replies.

h3nd

Programmer
Jul 1, 2006
147
AU
Hi guys,

Just simple function in ksh to convert string to number (integer) please.

Thanks
 
typeset -i

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thx PHV,

but how do I use it in my script.
I've tried this one.
Code:
for f in `ls -d *_Loaded`
do
        last=`echo $f | cut -f1 -d '_'`
        typeset -i $last
        echo $last
#       curr=expr $last+1
done

and the result is
Code:
MAILCHECK=600
OPTIND=1
PPID=11735
RANDOM=13017
SECONDS=0
TMOUT=0
1
MAILCHECK=600
OPTIND=1
PPID=11735
RANDOM=2115
SECONDS=0
TMOUT=0
2
MAILCHECK=600
OPTIND=1
PPID=11735
RANDOM=25881
SECONDS=0
TMOUT=0
3
 
Perhaps this ?
for f in $(ls -d *_Loaded)
do
typeset -i last=$(echo $f | cut -f1 -d '_')
echo $last
typeset -i curr=$((last+1))
echo $curr
done

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