What can I do about an "argument list too long" error in a shell command or script?

Solution Verified - Updated -


When trying to interact with a huge number of files from the command line or a shell script, it fails with an error message:

# ls *.txt
-bash: /bin/ls: Argument list too long

Or, when trying to delete a large number of files using find, it fails with an error message:

# find -type f -name '*.txt' -exec rm -i {} \;
-bash: /usr/bin/find: Argument list too long


  • Red Hat Enterprise Linux

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In