Shell script

Discussion in 'Mac Help/Tips' started by Irishgent, Nov 22, 2002.

  1. Irishgent macrumors newbie

    Nov 14, 2002
    I just want to increment the value of a variable in a shell script. I have tried

    count = count + 1
    Anyone got any ideas.
  2. bousozoku Moderator emeritus

    Jun 25, 2002
    Gone but not forgotten.
    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.
  3. Irishgent thread starter macrumors newbie

    Nov 14, 2002
    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)

    increment count by one


Share This Page