I want to efficiently do the following on the tcsh in Linux.
somecommand a;
somecommand b;
somecommand c;
If I do somecommand {a,b,c}
, this does somecommand a b c
, which is not what I want. Is there a way to do what I want?
I want to efficiently do the following on the tcsh in Linux.
somecommand a;
somecommand b;
somecommand c;
If I do somecommand {a,b,c}
, this does somecommand a b c
, which is not what I want. Is there a way to do what I want?
In Bash, it's for i in a b c; do somecommand $i; done
. I bet it's similar in tcsh.
@Borealid's loop is best. Just for kicks, another way is to use xargs:
echo a b c | xargs -n 1 somecommand
Thanks Boralid and John for your answers. I have created an alias in tcsh for this. It works!!
alias myglob 'echo !:2-$ | xargs -n 1 !:1'
In tcsh, you should use a foreach
loop, like this :
foreach val (a b c)
somecommand $val
end
Better yet would be to have the values in a variable, like this :
set values="a b c"
foreach val ($values)
somecommand $val
end