Results 1 to 15 of 15
  1. #1
    Join Date
    Apr 2004
    Location
    Atlanta, GA
    Posts
    541

    /bin/cp: Argument list too long

    i'm receiving the following error, can anyone help? i'm trying to copy files for a folder that has about 20,000 files.
    -bash: /bin/cp: Argument list too long

  2. #2
    Did you meen "FROM"?

    cd /your_dir
    cp * /dir_to (Only for files)
    cp -r * /dir_to (Files and folders)

    Bye

  3. I tried remove about 5,000 files with an 'rm' command and got the same error message. I wonder if this upper limit is hard coded or maybe it is dependant on machine memory???

  4. #4
    Originally posted by [email protected]
    I tried remove about 5,000 files with an 'rm' command and got the same error message. I wonder if this upper limit is hard coded or maybe it is dependant on machine memory???
    This is REALLY REALLY STRANGE!
    I was rm'ing more than 100K files with no problems.
    Maybe there is alot of directories inside and recursion worked not well
    Sorry, can't help.

  5. #5
    Edit: What I posted doesn't make any sense
    Pierre Grandmaison
    Offering 24/7 Toll Free Telephone Support
    Zenutech Web Hosting
    http://www.zenutech.com

  6. #6
    Join Date
    Oct 2003
    Posts
    566
    Problem's probably the * globbing.
    Code:
    /some/where:$ cp -R . /else/where
    Make sure that else isn't a sub directory of some.

  7. #7
    Join Date
    Apr 2003
    Location
    UK
    Posts
    2,560
    alternatively use xargs

  8. #8
    Join Date
    Jan 2003
    Posts
    1,715
    The * wildcard builds a command line and sends it to the command. The command line is limited to 128k (not sure where this is enforced, but I don't recommend changing it). xargs is a good suggestion that works by taking a list from standard input and slicing it into 128k pieces. Specifically, you can do this:

    find -type f | xargs rm

    Read 'man xargs' for other ways you can use it to build a command line.
    Game Servers are the next hot market!
    Slim margins, heavy support, fickle customers, and moronic suppliers!
    Start your own today!

  9. #9
    Join Date
    Jun 2003
    Location
    Myrtle Beach, SC
    Posts
    75
    some other alternatives are:

    rm [a-f]*
    rm [g-r]*
    etc. etc.

    or

    cd /path/to/rm
    find . -exec rm {} \;
    ---
    May this post be indexed by spiders, and archived for all to see as my internet epitaph.
    MikeSchroll.com

  10. #10
    Join Date
    Jun 2003
    Location
    Janesville, Wi
    Posts
    1,516
    How many files are you trying to copy? I used:

    cp -R /path/to/copy /path/to/paste

    Within /path/to/copy there was a little over 450,000 files.
    Jakiao

  11. #11
    Join Date
    Oct 2003
    Posts
    566
    Originally posted by Jakiao
    How many files are you trying to copy? I used:

    cp -R /path/to/copy /path/to/paste

    Within /path/to/copy there was a little over 450,000 files.
    So? There's no * in your command line, so it's obviously not a globbing issue. As I wrote above, the problem is with globbing, it doesn't occur when moving / copying directories by referencing the directory name.

  12. #12
    Join Date
    Jun 2003
    Location
    Janesville, Wi
    Posts
    1,516
    Hm ...

    I'll go run a similar command using * and reply after.
    Jakiao

  13. #13
    Join Date
    Oct 2003
    Posts
    566
    ~/tmp/bar$ for I in `seq 0 40000`; do touch file$I; done
    ~/tmp/bar$ mkdir ../foobar
    ~/tmp/bar$ cp * ../foobar/
    -bash: /bin/cp: Argument list too long
    ~/tmp/bar$ cd ..
    ~/tmp$ rmdir foobar
    ~/tmp$ cp -R bar foobar
    ~/tmp$

    HTH.

  14. #14
    Join Date
    Mar 2003
    Location
    California USA
    Posts
    13,294
    rsync -vrplogDtH /oldplace /newplace
    Steven Ciaburri | Industry's Best Server Management - Rack911.com
    Software Auditing - 400+ Vulnerabilities Found - Quote @ https://www.RACK911Labs.com
    Fully Managed Dedicated Servers (Las Vegas, New York City, & Amsterdam) (AS62710)
    FreeBSD & Linux Server Management, Security Auditing, Server Optimization, PCI Compliance

  15. #15
    Join Date
    Jan 2005
    Location
    Chicago
    Posts
    226
    here's a junky way to do this. It too can fail with too many files.

    ls -1 (or whatever makes a single column ls) |xargs cp [to wherever]

    find can be use used as well in place of ls. Be careful with xargs, it can do things you don't expect.
    Ken

    CROWHOST hosting+colocation services | 877-CROWHOST | support at crowhost.com
    Independent remote-hands serving all Chicago data centers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •