LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-15-2003, 08:45 AM   #1
lovedaddy
LQ Newbie
 
Registered: Dec 2002
Distribution: Slackware 8.1
Posts: 3

Rep: Reputation: 0
cp - why is this so difficult


Got a dir with a load of file containing spaces.
Want to copy them to another location.
cp returns "Argument list too long".

I got as far as realising I need ls -Q (to get a listing with quotes round the file names) and passing that to xargs - but I cannot get the last bit.

Any help would be great.

Cheers
 
Old 03-15-2003, 08:59 AM   #2
niknah
Member
 
Registered: Dec 2002
Location: In front of a computer
Distribution: UPS, DHL, FedEx
Posts: 466

Rep: Reputation: 38
type cp -a /dir /destinationdir

if you dont want to copy everything in your dir you need to copy a little bit at a time, like...
cp a* /destdir
cp b* /destdir

this is a shell problem, it can't handle too many filenames.

to use ls -Q, try...
cp `ls -Q` /destdir
 
Old 03-15-2003, 09:56 AM   #3
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464

Rep: Reputation: 52
I do like ls -Q, always something new to use.

For xargs, do the following:

ls -Q|xargs cp {} /destdir
 
Old 03-15-2003, 06:29 PM   #4
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
do this instead:

Code:
cd /srcdir
tar cvf - . | ( cd /destir; tar xf -)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
this is really difficult drevil666 Linux - Software 9 06-25-2005 09:50 AM
how difficult is it? batgranny Linux - Networking 1 04-11-2005 06:52 PM
Is it really that difficult? Tesl General 8 09-07-2003 03:20 AM
Just how difficult Valael Linux - Newbie 6 03-05-2003 02:56 PM
Why so difficult ? gemcgrew Linux - Newbie 14 10-31-2002 01:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration