/bin/rm: cannot execute [Argument list too long]

Error

/bin/rm: cannot execute [Argument list too long]

Cause

rm can only handle a certain number of arguments. If you run following command in a directory of 500 json files, the argument list is 500

$ rm -f *.json

Solution

Use find or find coupled with xargs as follows:

$ find . -name "*.json" -print0 | xargs -0 rm

or

$ find . -name "*.json" -delete

Technologies: 
Actions: