I have a file that contains all the file names, eg
a.txt
abc.log
xyz.out
I want to prepare a script and make it become
mv a.txt /home/wendy/script
mv abc.log /home/wendy/script
mv xyz.out /home/wendy/script
From here, I want to execute this file.
Rdgs
Marcus
Sent via Deja.com http://www.deja.com/
Before you buy.
In case you don't really need the intermediate script, see
man xargs
--
Ronald Fischer <rona...@my-deja.com>
http://profiles.yahoo.com/ronny_fischer/
I never understood xargs. Isn't backticking sufficient? In this case, it would be
mv `cat INFILE` /home/wendy/script
--
|_ _ _ __
|_)(_)| ) ,'
-------- '-._
--
Posted from relay4.inwind.it [212.141.53.75]
via Mailgate.ORG Server - http://www.Mailgate.ORG
Depends on how big INFILE is. There is a limit to the amount of
data the kernel is willing to pass through command line arguments;
the value of xargs is that it will chunk the arguments passed on
its standard input, giving better performance than a loop that
fires of a new command instance for each argument, and better
robustness than using backticks when there is no guarantee that
the input length will be less than ARG_MAX.
--Ken Pizzini
xargs breaks up the input so that the command line is never too big.
No matter how big INFILE is, it won't break xargs. It will simply
run as many instances of mv as it has to to cope with all the entries.
Chris Mattern
for i in `cat INFILE`; do mv $i /home/wendy/script; done
will avoid the args too long problem.