Solved

Copy maximum

Posted on 2001-06-26
1
178 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

12 Experts available now in Live!

Get 1:1 Help Now