Solved

Copy maximum

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
list of sudo access for date range 5 38
CentOS Backup Options 3 68
Require Script-Linux 4 15
LInux Mint to VPN with Sonic Firewalls 2 15
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

752 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