1. IMPORTANT - 11/13/2015: In light of a possible breach we have scrubbed all passwords. You will need to request a password reset through the site. Click here for more information.

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

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

  1. Rob

    Rob Administrator Staff Member

    Oct 27, 2011
    Likes Received:
    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 New Member

    Aug 22, 2012
    Likes Received:
    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 New Member

    May 28, 2012
    Likes Received:
    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