The solution to delete a large number of files under linux prompts that the parameter is too long

The solution to delete a large number of files under linux prompts that the parameter is too long

https://blog.csdn.net/ls198825/article/details/7529570

When deleting a large number of files in linux, using rm directly will cause an error: -bash: /bin/rm: parameter list is too long.

This can be combined with the find command.

Delete files in the current directory that contain the name field in the file name or folder name:

find . -name "name*" | xargs rm -rf


If the filename or folder name contains spaces:

find . -name "name*" -print0 | xargs -0 rm -rf

find . -name "*.jpg"| xargs rm -rf "*.jpg" delete JPG images


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324643242&siteId=291194637