Solved

Copy files - Argument list too long

Posted on 2009-07-11
11
1,045 Views
Last Modified: 2013-11-22
I ran this:

cp 1241* /usr/local/virtual/domain.com/mailman/new/

And got the following error:

/sbin/cp: Argument list too long.

Any ideas?
0
Comment
Question by:hrolsons
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 12

Expert Comment

by:Let_Me_Be
ID: 24831895
* is expanded before calling the command. If you have to many files starting with 1241 the argument list might be indeed to long.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24831911
Hi,

use 'find' and 'xargs'. Assuming '/dir' was the directory containing the files, issue

find /dir -type f -name 1241\* | xargs -I{} cp {} /usr/local/virtual/domain.com/mailman/new/

That should do the trick.

wmp
0
 

Author Comment

by:hrolsons
ID: 24831935
woolmilkporc,

What would I put in place of "/dir" if I am already in the directory I'm going to copy files from?
0
 
LVL 12

Expert Comment

by:Let_Me_Be
ID: 24831939

`pwd`

Open in new window

0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24831941
Just a dot ( . )
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:hrolsons
ID: 24831953

find . -type f -name 1241\* | xargs -I{} cp {} /usr/local/virtual/domain.com/mailman/new
 

xargs: {}: No such file or directory

Open in new window

0
 

Author Comment

by:hrolsons
ID: 24831955
'pwd'???
0
 

Author Comment

by:hrolsons
ID: 24831962
Sorry, pwd is:

/usr/local/virtual/domain.com/all/cur
0
 
LVL 12

Expert Comment

by:Let_Me_Be
ID: 24831970
Its not 'pwd' but `pwd` Anything between `` will be executed and the output will be used in the place where you wrote it.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 24832002
As for the error - maybe xargs for FreeBSD needs a space between '-I' and '{}'. Try

find . -type f -name 1241\* | xargs -I {} cp {} /usr/local/virtual/domain.com/mailman/new

If that doesn't work neither, try

find . -type f -name 1241\* | xargs -J % cp % /usr/local/virtual/domain.com/mailman/new

..and 'new' should be a directory and must already exist!
 
0
 
LVL 61

Expert Comment

by:gheist
ID: 24832020
cp 1241\* /usr/local/virtual/domain.com/mailman/new/
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now