Positional parameters in the C-shell
In csh, you need to assign an array argv
:
> set argv=(hi how are you)
> echo $1
hi
Explanation:
argv
is an array variable that contains a list of command line arguments (the 0th argument is the name when invoking the shell, and the other is from the 1st index). Variables $0
- $n
also contain the values โโof the arguments. So it $argv[1]
matches $1
. To assign an array variable, you can use either set arr=(value1 value2)
or set arr[1] = value1
.
set value1 value2
will work in bash
, but csh
should be similar to C, so an array is used argv
(read a little about C program command line arguments if you don't know why).
But in csh
this: set first second
means assigning an empty (zero) value to the variables first
and second
.
source to share