Currently using csh at workplace.
So what i currently have is a path stored in the first line of a file and i am trying to read that.
head -n 1 jvar.txt
Now i have to go to that path so i was trying to store this in a variable
set a = head -n 1 jvar.txt
but its not able to store it in sayin Illegal variable name. The idea was to then do cd $a and go to that path. is there any way i can store it to something so i can cd to that path.
To capture the output of the head command into a string that you can assign to a variable, you need command substitution.
In
csh
, that is done by enclosing the command in backticks:The backtick syntax also works in
bash
, but is deprecated in favour of$(...)
. Also note that in bash and similar Bourne/Korn derived shells, it is an error to include whitespace around the=
operator: