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!

subtract in sghell script 1

Status
Not open for further replies.

TheDash

MIS
Mar 25, 2004
171
US
Hi,

How to subtract in shell script. for example $value -1 ?

i.e In an expression I want $value -1

Thanks
 
TheDash,

Use the let command.

Ex.

Code:
value=100
let value=$value-10
echo $value

The value of the variable value would be 90.

John
 
In ksh:
((value-=1))

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Another way (sh, bash, ksh) :
[tt]value=`expr $value - 1`[/tt]

The PHV solution works also with bash

Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top