Solved

Copy maximum

Posted on 2001-06-26
1
183 Views
Last Modified: 2010-04-20
sometimes when I use the cp command to copy files, I get the error code agument list too long.

This happens when I'm using
(1)> cp dira/* dirb/

I can copy the files recursively by using
(2)> cp -r dira/ dirb/
but the files will go to directory "dira/dirb/"

Of course there are many ways to get the files from "dira" to "dirb". Copying them with a script or using other stupid tricks, but my question is, why is there a maximum number for the command (1). And maybe someone has an elegant way to avoid this.
I'm using SUSE.Linux 6.0
0
Comment
Question by:JWTtheTh
1 Comment
 
LVL 40

Accepted Solution

by:
jlevie earned 100 total points
ID: 6227478
That's a limitation of the shell, not the cp command. When you use wildcards like that the shell expands the wildcard into a list of filenames that it passes to the command. If the wildcard expands to a large number of items the internal buffer in the shell can be filled and the command truncated.

A better way of copying large directories is to use tar in a pipe, like:

# cd dira
# tar cf - . | (cd /path-to/dirb; tar xvf -)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

713 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