If you, as a system administrator, wanted to delete a folder that has a large number of files with the rm command on the command line, you have probably encountered the following error.
[root@server1] # rm -rf * -bash: /bin/rm: Argument list too long
At this time, with a simple solution and an alternative command, you can easily perform the cleanup and removal operation.
- If you want to remove all file existing in the folder, use this command :
find . -type f -exec rm -v {} \;
2. If you want to remove specify type of file, for example PDf file try like :
find . -name ‘*.pdf’ -exec rm -f {} \;
Finally, I recommend that you use the command carefully and be careful, because incorrect use of this command may cause the operating system to crash.