Mar 26, 2004 #1 TheDash MIS Joined Mar 25, 2004 Messages 171 Location US Hi, How to subtract in shell script. for example $value -1 ? i.e In an expression I want $value -1 Thanks
Hi, How to subtract in shell script. for example $value -1 ? i.e In an expression I want $value -1 Thanks
Mar 26, 2004 #2 johngiggs Technical User Joined Oct 30, 2002 Messages 492 Location US 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 Upvote 0 Downvote
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
Mar 26, 2004 #3 johngiggs Technical User Joined Oct 30, 2002 Messages 492 Location US FYI - That's a ksh command. John Upvote 0 Downvote
Mar 26, 2004 #4 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location FR In ksh: ((value-=1)) Hope This Help, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 Upvote 0 Downvote
In ksh: ((value-=1)) Hope This Help, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
Mar 29, 2004 1 #5 Martin999 Technical User Joined Feb 26, 2004 Messages 298 Location US try : echo "$VALUE-1" |bc works for me .... Martin Upvote 0 Downvote
Mar 29, 2004 #6 aigles Technical User Joined Sep 20, 2001 Messages 464 Location FR Another way (sh, bash, ksh) : [tt]value=`expr $value - 1`[/tt] The PHV solution works also with bash Jean Pierre. Upvote 0 Downvote
Another way (sh, bash, ksh) : [tt]value=`expr $value - 1`[/tt] The PHV solution works also with bash Jean Pierre.