Re: cp list of files into another directory
- From: "M. Ahman" <ahman@xxxxxxxxxxxxxx>
- Date: 8 May 2006 20:43:38 +0200
On 08 May 2006 17:09:13 GMT
Stephane Chazelas <stephane_chazelas@xxxxxxxx> wrote:
On 8 May 2006 08:52:56 -0700, Sashi wrote:
[...]
pawan_test wrote:
Hi All,
i am trying to copy files from a directory to another.
here is what I am doing
ls -ltr INTER*
THE output is list of 80 files.
i have to copy all these 80 files into another directory
( say /home/pavi/folder) at a time.
can anyone please suggest me how do I do it.
thanks
pavi
If the file names do not contain spaces, a simple cp command would do:
cp INTER* /destination/directory/name/.
Whether the file names contain spaces or not will make no
difference (why would it?).
It may fail if the list of files, combined with the other
arguments and the environment is too big and reaches the systems
limit for the execve(2) system call.
In that case, you can do:
ls | sed -n '/^INTER/s/./\\&/gp' | xargs sh -c '
shift "$1" && exec cp "$@" /destdir' 2 1
(fails if file names may contain newline characters)
Or
find . \! -name . -prune -name 'INTER*' -exec sh -c '
shift "$1"
exec cp "$@" /destdir' 2 1 {} +
Or (but it runs a cp for every file):
for f in INTER*; do
cp "$f" /destdir
done
And people say UNIX is difficult to use...
:)
--
Magnus
.
- References:
- cp list of files into another directory
- From: pawan_test
- Re: cp list of files into another directory
- From: Sashi
- Re: cp list of files into another directory
- From: Stephane Chazelas
- cp list of files into another directory
- Prev by Date: Re: recursive diff matching a pattern
- Next by Date: Re: replacing newlines?
- Previous by thread: Re: cp list of files into another directory
- Next by thread: Re: cp list of files into another directory
- Index(es):
Relevant Pages
|