Operating System - HP-UX
1834009 Members
1853 Online
110063 Solutions
New Discussion

Re: Help! I've gone brain dead

 
SOLVED
Go to solution
Mark Fenton
Esteemed Contributor

Help! I've gone brain dead

and can't recall how to increment a variable in shell!

I want to do something like:

VAR=1
for blah blah blah
do
VAR=$VAR+1
echo $VAR > somewhere
do some other stuff
done
((is today Monday again?))
7 REPLIES 7
S.K. Chan
Honored Contributor

Re: Help! I've gone brain dead

((VAR+=1))
Mark Greene_1
Honored Contributor
Solution

Re: Help! I've gone brain dead

try this:

VAR=1
(( VAR = $VAR + 1 ))
echo $VAR


HTH
mark
the future will be a lot like now, only later
harry d brown jr
Honored Contributor

Re: Help! I've gone brain dead

Mark,

To be brain dead, you have to be in management!

live free or die
harry
Live Free or Die
Helen French
Honored Contributor

Re: Help! I've gone brain dead

Mark,

Yes ..I agree with Harry ! So visit the admin (prefer HP-UX admin) session some times !

Shiju
Life is a promise, fulfill it!
Darrell Allen
Honored Contributor

Re: Help! I've gone brain dead

Hi Mark,

Another method:
VAR=`expr $VAR + 1`

Sounds like Harry and Shiju have had some of the same managers I've had! Ya'll didn't use to work at...

Well, better left unsaid!

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
James R. Ferguson
Acclaimed Contributor

Re: Help! I've gone brain dead

Hi Mark:

In keeping with more-than-one-way:

# let X=X+1

Regards!

...JRF...
Mark Fenton
Esteemed Contributor

Re: Help! I've gone brain dead

Thanks all.

Harry -- I have to apologize -- if I had thought about it, the chuckle should have been worth at least 10.

All others, thanks for breathing life back into a frazzled admin......

This forum is great.