cp list of files into another directory

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

Well, there are MANY ways of doing so!
First and most common is to see if these files have anything in common in their names. If they do you can use the wildcards, something like that: afile or a???file and so on.
? stands for any symbol within a name and * for any numbers of symbols within the name
Then you simply:
cp INTER
/home/pavi/folder, or if the files simply all the files in a directory
cp * destinationdirectory

You also can do the same with find and cpio combination and with xargs . While you need to copy between different systems clones cpio works the best as it preserves file attributes (as different systems assign different meanings for options of cp command). If you copy within same machine cp will do just fine.

Get �UNIX Essentials and UNIX Core� DVD if you have questions of this sort.

Hope it helps.

Here is one way:

tar -cf - INTER* | (cd /home/pavi/folder ; tar -xvf -)

Hi All,

thanks for all your suggestions.
I have a question;

ls -ltr INTER*
( The output is list of 80 files.)

DAT=`ls -ltr $DIR_NAME/INTER* | wc -l`>/dev/null 2>/dev/null
echo " the number of files are $DAT"

cp $DIR_NAME/INTER* /home/pavi/folder
( i have to copy all these 80 files into another directory )

here i want to output may be through an say echo statement that all 80 files have been copied.

can anyone please suggest me how do I do it.

thanks
pavi

#!/bin/ksh

let filecnt=0
for file in `ls -1 INTER*`
do
   cp "$file"  /other/directory
   let filecnt=$filecnt+1
done
echo "$filecnt files copied"