From: Padraig Brady (padraig at domain antefacto.com)
Date: Wed 19 Jun 2002 - 11:40:10 IST
Justin MacCarthy wrote:
> Is it possible to pipe into mv ??
>
> I want to do something like
>
> find / 'foobar*' | mv /destfolder
>
> i.e. move all files called foobar* into destfolder
>
> I know find has an -exec flag but I was just wondering ...
already mentioned is xargs, ie
find / -name 'foobar*' -print0 |
xargs -r0 mv /destfolder
this will create command line(s) like:
mv /destfolder file1 file2 ...
which is obviously not what you want.
So the helpful people at domain gnu have added
the --target-directory option to mv (and cp etc.).
so what you want is:
find / -name 'foobar*' -print0 |
xargs -r0 mv --target-directory=/destfolder
Note the alternative below is not nearly
as good, a a seperate mv process will be
used for each file:
find / -name 'foobar*' -print0 |
xargs -0i mv '{}' /destfolder
Note there also is a bug in xargs wrt this.
xargs -0i is OK whereas xargs -i0 breaks.
Padraig.
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:17:20 GMT