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
Solved

Copy files - Argument list too long

Posted on 2009-07-11
11
1,078 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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

Expert Comment

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

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

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…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

828 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