Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

script to move files from one dir to another

2 views
Skip to first unread message

marcu...@my-deja.com

unread,
Dec 5, 2000, 10:55:50 PM12/5/00
to
Hi,

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.

Ronny

unread,
Dec 6, 2000, 3:00:00 AM12/6/00
to
In article <90kdc4$ce1$1...@nnrp1.deja.com>,

marcu...@my-deja.com wrote:
> 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.

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/

Bonz

unread,
Dec 10, 2000, 1:11:08 PM12/10/00
to
> >man xargs

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

Ken Pizzini

unread,
Dec 10, 2000, 9:49:16 PM12/10/00
to
On 10 Dec 2000 19:11:08 +0100, Bonz <bon...@gnu.org> wrote:
>> >man xargs
>
>I never understood xargs. Isn't backticking sufficient? In this case, it would be
>
>mv `cat INFILE` /home/wendy/script

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

Chris Mattern

unread,
Dec 11, 2000, 10:03:02 AM12/11/00
to
"Bonz" <bon...@gnu.org> wrote in message news:3A33C690...@gnu.org...

> > >man xargs
>
> I never understood xargs. Isn't backticking sufficient? In this case, it would be
>
> mv `cat INFILE` /home/wendy/script
>
And what do you do if it comes back "mv: parameter list too long"?

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


Michael Wang

unread,
Dec 22, 2000, 11:52:37 PM12/22/00
to
>>I never understood xargs. Isn't backticking sufficient? In this case,
>it would be
>>
>>mv `cat INFILE` /home/wendy/script
>
>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;

for i in `cat INFILE`; do mv $i /home/wendy/script; done
will avoid the args too long problem.

0 new messages