Solved

Copy maximum

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

Stack Overflow Podcast - Frustrating Miracles

In this podcast, Stack Overflow interviewed Linux Academy CEO/Founder, Anthony James, and got his developer story!

"Follow your passion, be prepared to work hard and sacrifice, and, above all, don't let anyone limit your dreams."  - Donovan Bailey

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

635 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