copying files with spaces in the filename

Hi

I am having difficulty copying files from one dir to another due to a space in the names of the file with an extension .rtf

There are a group of files and the command am using is

cp `ls -rt /wlblive/home/whiops/ops/RTFs/*.rtf|head -20` /wlblive/home/jamshed

Since the files are like "EUJUL4_VF70864331401_WILLIAM ROYTMAN.rtf" where there is a space as you notice in the name the copy command fails.

Please help.

cp "$(ls -1rt /wlblive/home/whiops/ops/RTFs/*.rtf | head -20)"
The ls options are 1 (ONE) not l to get a single column.
The quotes are to see it as one file even with a space in its name.

Good Luck

You can try with loop.

 
ls *rft | head -20 >tmp
while read file
do
cp "$file" ./chk
done<tmp

That works....Many Thanks!!!!

---------- Post updated at 08:59 AM ---------- Previous update was at 08:43 AM ----------

Hi

I have managed to copy a few files into a directory but since there are too many files it looks a bit untidy .

Is there a way i can directly copy all of them into a compresses file(.gz).

This would make it easier to ftp the file as well...Many Thanks