#####################################################################################################
#find ...-exec rm {} \;
The find command can be found to delete the results, the difference is simply the former is to find the results of the search to the EXEC option, so when the number of files, there may be "too many parameters" error.
-exec must be made up of one; End, and because usually the shell will be right; For processing, so use \; Prevent this situation. {} may need to write ' {} ', also to avoid being filtered by the shell
EG1:
[[email protected] xusx]# Touch 1.sh 2.sh 3.sh 1.txt 2.txt 3.txt
[[email protected] xusx]# ls
1.sh 1.txt 2.sh 2.txt 3.sh 3.txt passwd
[[email protected] xusx]# Find/-type f-name "passwd"-exec rm {} \;
[[email protected] xusx]# ls
1.sh 1.txt 2.sh 2.txt 3.sh 3.txt
#####################################################################################################
#find ... | Xargs RM-RF
This command avoids this error because the Xargs command will process the results in batches. So it seems, "find ... | Xargs RM-RF "is a more general method, recommended use!
RM does not accept standard input, so you cannot use Find/-name "Tmpfile" |rm
EG1:
[[email protected] a]# ls
1.sh 1.txt 2.sh 2.txt 3.sh 3.txt
[[email protected] a]# Find/-type f-name "1.sh" |xargs rm-f
[[email protected] a]# ls
1.txt 2.sh 2.txt 3.sh 3.txt
#####################################################################################################
./ indicates a search from the current directory
-type F, which means that only files, file types, directories, and other bytes are found.
-exec passes the file name of find to the following command line instead of the {} part
-exec after the command line, you must use "\;" End
Find./-name *.bak | Xargs RM-RF