| Will O'the Wisp ( @ 2009-05-18 14:44:00 |
Unix question
I have a unix script (called, say, doit) that contains
variables $1, $2, $3.
I also have a file (called, say, stringlist) that looks
like this:
a
b
c
I want to write a new script (called, say, newscript)
such that invoking the command "newscript stringlist"
is equivalent to invoking the command "doit a b c".
And of course if I have a file called otherstringlist
with contents
d
e
f
then "newscript otherstringlist" should be equivalent
to "doit d e f".
How do I do this?
(PS: In case it matters, I prefer a solution that works
under tcsh.)
(Double PS: What I'm currently doing is editing the file
stringlist to replace the line "a" with a sed command
that changes "$1" to "a" in doit, and likewise for all
other lines (i can co this with a 1,$s/^/.... and a
1,$s/$/ ...), then running the resulting script to create
a new script without any variables that I can just run. But
surely there's a better way?)
I have a unix script (called, say, doit) that contains
variables $1, $2, $3.
I also have a file (called, say, stringlist) that looks
like this:
a
b
c
I want to write a new script (called, say, newscript)
such that invoking the command "newscript stringlist"
is equivalent to invoking the command "doit a b c".
And of course if I have a file called otherstringlist
with contents
d
e
f
then "newscript otherstringlist" should be equivalent
to "doit d e f".
How do I do this?
(PS: In case it matters, I prefer a solution that works
under tcsh.)
(Double PS: What I'm currently doing is editing the file
stringlist to replace the line "a" with a sed command
that changes "$1" to "a" in doit, and likewise for all
other lines (i can co this with a 1,$s/^/.... and a
1,$s/$/ ...), then running the resulting script to create
a new script without any variables that I can just run. But
surely there's a better way?)