[Techtalk] copying similar files in one command
Kathryn Hogg
kjh at flyballdogs.com
Mon Nov 1 03:38:56 EST 2004
Magni Onsoien said:
> You may use wildchars and let your shell take care of finding the files
> for you (this is called file expansion):
>
> cp *ed* /home/newdir
I always recommend using a trailing "/" if the destination is a directory:
cp *ed* /home/newdir/
Why? Because if /home/newdir doesn't exist, the first form will happily
copy *ed* to a file named /home/newdir. The result is that it will
ultimately just contain a copy of the last file.
This isn't the worst thing with cp, but if you were renaming the files:
mv *ed* /home/newdir
It could be disasterous since all but the last file in the pattern match
would be gone.
If you append the trailing "/", it will force the destination to be
treated as a directory and should fail it neither exists or is a file.
--
Kathryn
http://womensfooty.com
More information about the Techtalk
mailing list