One of the directories has millions of files, which is no more required. When trying to delete all files from that folder using the
rm command, I got this error message
/bin/rm : Argument list too long
If there are a large number of files in a single directory, Then the traditional
rm command can not delete all files and ends with an error message
Argument list too long.
To resolve this issue and delete all files use xargs command-line utility with the find command.
- First change to the directory where all files exists:
- Then execute command to delete all files in current directory and its sub directories.
WARNING – This will also delete files from subdirectories. Be careful with this command.
find . -name '*' | xargs rm
That’s it. you will find all files are deleted now.