Os M Torvalds
Os M Torvalds

Reputation: 21

set var in Csh script

I'm creating a script like this

#!/bin/csh

set h=1;

while [h=1] do  echo "hi"; h=2; done;

but when I execute it a get this:

===> message after : csh test.sh     [h=1]: No match. 

Upvotes: 0

Views: 4422

Answers (1)

Barmar
Barmar

Reputation: 780879

Try:

set h = 1

while ( $h == 1 )
  echo "hi"
  set h = 2
end

You seem to be trying to mix Bourne shell syntax into your C shell script.

Csh is generally a lousy language for scripting, try to avoid it if at all possible

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

UPDATE:

The csh equivalent to read h is:

set h = $<

Upvotes: 1

Related Questions