Solved

Copy files - Argument list too long

Posted on 2009-07-11
11
1,134 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.

717 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