How To Work Around “Argument List Too Long” Error Deleting a Gazillion Files Under Linux

You can receive the error argument list too long trying to execute a rm -f * in a directory with a lot of files but there is a very simple workaround.  Simply execute this instead to delete the files…

find . -name "*" -type f -maxdepth 1 -exec rm {} \;

Important: Executing a find . -exec rm {} \; is equivalent to executing a rm -f * — be sure you know what you are doing and be sure you are in the right directory when you execute this.

Note that the -name "*" switch avoids deleting system files and the -maxdepth 1 switch avoids deleting files in subdirectories.

4 Responses to “How To Work Around “Argument List Too Long” Error Deleting a Gazillion Files Under Linux”

  1. Note that there’s a difference between the two. The workaround you present will delete hidden files (those that start with a dot) and the content of any folders in the directory you’re deleting from, while the original will not.

    If you’re okay with that, a simpler workaround would simply be to delete the directory containing the files you want to delete.

  2. Kent Johnson says:

    Excellent clarification, thanks. I’ve changed to avoid recursing into subdirectories.

  3. ….

    Я извиняюсь, но, по-моему, Вы не правы. Я уверен. Давайте обсудим. Пишите мне в PM….

  4. JUAN says:


    Medicamentspot.com. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. No prescription pills. Order pills online

    Buy:Viagra Soft Tabs.Cialis Professional.Viagra Super Active+.Cialis.Viagra Super Force.Viagra Professional.Cialis Soft Tabs.Maxaman.Propecia.Cialis Super Active+.Super Active ED Pack.Levitra.VPXL.Viagra.Tramadol.Soma.Zithromax….

Leave a Reply