Several classic combinations of find and rm

Find all the files starting with a in the root directory and pass the search results as parameters to the rm -rf command to delete:
1. find / -name “a*” |xargs rm -rf
2. find / -name “a* "-Exec rm -rf {};
3. rm -rf $(find / -name “a”)

If you want to specify the recursion depth, you can do this:
1. find / -maxdepth 3 -name “ .mp3” |xargs rm -rf
2. find / -maxdepth 3 -name “a
”-exec rm -rf {};
3. rm -rf $(find / -maxdepth 3 -name "a")
This will only find the qualified files in the three-level directory and delete them!

Guess you like

Origin blog.csdn.net/u014442879/article/details/108615140