Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copy files - Argument list too long

Posted on 2009-07-11
11
Medium Priority
?
1,277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 

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 2000 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 62

Expert Comment

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

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.
Suggested Courses

609 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