Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd please sign up again. Thanks!

/bin/rm: Argument list too long (find's delete flag!)

Discussion in 'Command Line' started by Rob, Dec 2, 2011.

  1. Rob

    Rob Guest

    At some point in your Linux life you'll come across a directory of session files (or something similar) that you want to remove. BUT, when you try to remove the files with linux's rm command you're met with the error message:

    /bin/rm: Argument list too long




    Fret not.. use find to remove these session files with it's -delete flag!

    Let's say we're looking to delete files named session_848938, session_45949343, session_454344, etc.. and they live in /path/to/files/

    [xcode=bash]find /path/to/files/ -name "session_*" -delete[/xcode]

    Before I found out about find's cool -delete flag I'd pair up find with exec or xargs..

    [xcode=bash]find /path/to/files/ -name "session_*" -exec rm {} \;
    find /path/to/files/ -name "session_*" -print0 | xargs -0 rm[/xcode]

    Now, however.. i'll use the -delete flag.

    Does anyone know how long it's been around?
     
  2. fijiaaron

    fijiaaron Guest

    I don't know how long it's been around, but on my Ubuntu 8.10 the delete flag is listed in the man page, but it doesn't work. I get this message:

    find: invalid predicate `-delete'
     
  3. Bill

    Bill Guest

    8.10 is fairly old. Ubuntu 12.10 will be out in a few months. 8.10 is nearly 4 years old. Have you considered upgrading?
     

Share This Page