Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Irishgent

macrumors newbie
Original poster
Nov 14, 2002
8
0
I just want to increment the value of a variable in a shell script. I have tried

count = count + 1
Anyone got any ideas.
 
It depends on the shell.

Bourne shell (sh): count='expr $count + 1'
C shell (csh): @ count += 1 or @ count++
Bourne again shell (bash): count = count + 1

The sh form should work with Korn shell (ksh) and the csh form should work with Tcsh.
 
while, if syntax for tcsh

I want to make a while loop so in for tcsh.

What is the correct syntax.

set count = 1
set max = 5

while (count < max)
do

increment count by one

done
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.