Reading a variable in csh

I have a simple script that sets a value and reads the value in csh:

set -x
set a = 10
echo $a

The output of the script does not show the value of a

+ set a = 10
+ echo

any help would be great.

I think CSH uses "setenv" to set environment variables.

1 Like

I dont need to make it an environment variable

Hi

Are you sure you are running your script in csh? Because 'set -x' will throw an error in csh since 'set' should follow a variable name.

It looks to be it is some other shell such as ksh/sh, which is why on doing 'set -x', it went into debug mode, and on giving 'set a = 10', it did not set 10 to a, instead it made the string 'a=10' as a command line argument($1).

Guru.

1 Like

I missed the shebang. It works now!