"James (Jim) Hatridge" wrote:
>
> HI all,
>
> I'm trying to "find" all .gif files and "mv" them to another dir. Here is
> what I am using (all on one line):
>
> find /home/hatridge/.netscape/cache/ -mindepth 2 -name "*.gif" -exec mv \{
> \} /home/hatridge/.gif \;
>
> But instead of having all the gif files in the new dir here is what I'm
> getting:
>
> mv: {: No such file or directory
> mv: }: No such file or directory
> mv: {: No such file or directory
> mv: }: No such file or directory
>
> Any ideas what I'm doing wrong?
>
<snip>
I'd use
$ find /path -name '*.gif' -print0 | xargs --null --replace=file \
mv file /destination
(only to show a seldom used switch for xargs), where /destination _must_
not contain the string 'file'. The xargs command can be abbreviated:
$ find /path -name '*.gif' -print0 | xargs -0ifile mv file /destination
or
$ mv $(find /path -name '*.gif') /destination
which is much faster for many files, because mv is only invoked once,
but can lead to errors about too long command lines (simply try it).
The fisrt solution is not disturbed by filenames that contain whitespace
or even backslashes, while the second might well be. If you alter the
second to be
$ ( IFS=$'\n'; mv $(find /path -name '*.gif')
/destination )
(the newline is necessary?) then it will mv your whitespace-containing
files, too.
If you want it to work _now_, use the first, if you want to experiment,
use the second (which is untested).
Hope this helps,
Marc
--
Marc Mutz <[EMAIL PROTECTED]> http://marc.mutz.com/Encryption-HOWTO/
University of Bielefeld, Dep. of Mathematics / Dep. of Physics
PGP-keyID's: 0xd46ce9ab (RSA), 0x7ae55b9e (DSS/DH)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs