While loop in tcsh



Hi,

I was trying to code a simple while loop in tcsh shell.

#!/bin/tcsh
set cnt=5
while ($cnt > 0)
cnt = $cnt(`expr($cnt - 1))
end

However I am getting the following error :
cnt=4: command not found (Error is going on till <ctrl+c> is pressed.

Is this an error with the syntax?

Thanks
Unix baby

.



Relevant Pages

  • Re: While loop in tcsh
    ... Melvin writes: ... I was trying to code a simple while loop in tcsh shell. ... there are two ways to decrement cnt: ...
    (comp.unix.shell)
  • Re: While loop in tcsh
    ... I was trying to code a simple while loop in tcsh shell. ... while ($cnt> 0) ... Is this an error with the syntax? ...
    (comp.unix.shell)
  • Re: While loop in tcsh
    ... Melvin wrote: ... I was trying to code a simple while loop in tcsh shell. ... while ($cnt> 0) ... You left out the command "set" in the assignment inside the loop. ...
    (comp.unix.shell)
  • Re: While loop in tcsh
    ... I was trying to code a simple while loop in tcsh shell. ... while ($cnt> 0) ... For math operations we have the @ operator in the c-shell & it's ilk, ...
    (comp.unix.shell)
  • Re: a for loop stops before it reaches the end.
    ... I believe that it's always a good idea to avoid programming by side-effect - in this case, your method should return the sorted ... Your outer loop needs to loop according to the size of the ArrayList passed in, but you need to make a copy of that ArrayList before you ... Ant a = fromList.get; int cnt = 0; ...
    (comp.lang.java.help)