find . -name "*.txt" -exec rm {} \;
find . -name "*.txt" | xargs rm {} 

    1. Parameters are passed one by one , Pass a parameter to execute once rm
    2. File names can also be processed with special characters such as spaces
    1. Pass parameters to commands at once , have access to -n Number of control parameters
    2. Handling special filenames requires the following :
    find . -name "*.txt" print0 |xargs -0 rm {} 

The experimental results are as follows , You can clearly see the parameter passing process

[ ~/tmp/dir]#find . -type f |xargs -t -n 2 echo echo ./data.txt
./env2.txt ./data.txt ./env2.txt echo ./env.txt ./export2.txt ./env.txt
./export2.txt echo ./s.txt ./d.txt ./s.txt ./d.txt echo ./export.txt ./set.txt
./export.txt ./set.txt echo ./fuck.txt ./fuck.txt [
~/tmp/dir]#find . -type f -exec echo begin {} \; begin ./data.txt begin
./env2.txt begin ./env.txt begin ./export2.txt begin ./s.txt begin ./d.txt
begin ./export.txt begin ./set.txt begin ./fuck.txt [ ~/tmp/dir]#

skill : find -print0   And xargs -0 Avoid special characters such as spaces in file names , Quotation marks, etc. cannot be processed :

 find . -name "*.txt" print0 |xargs -0 rm {} 


       -print True; print the full file name on the standard output, followed
by a newline.   If you are piping the
              output of find into another program and there is the faintest
possibility that the  files  which  you
              are  searching  for  might  contain  a  newline, then you
should seriously consider using the -print0
              option instead of -print.  See the UNUSUAL FILENAMES section
for information about how unusual  char-
              acters in filenames are handled.

              True;  print  the full file name on the standard output,
followed by a null character (instead of the
              newline character that -print uses).  This allows file names
that contain newlines or other types  of
              white space to be correctly interpreted by programs that
process the find output.  This option corre-
              sponds to the -0 option of xargs.


       -0     Input items are terminated by a null  character  insteadof  by
     whitespace,  and the quotes and backslash are not special (every
     character is taken literally).  Disables the end of file string,
     which  istreated  like any other argument.  Useful when input
     items might contain white space, quote  marks,  or  backslashes.
     The  GNU find  -print0  option produces input suitable for this

©2019-2020 Toolsou All rights reserved,
Map---Java judge Map Contains a key Theory and formula derivation of univariate linear regression and multiple linear regression Vue Get the text and option value of the drop-down box [AndroidO] [RK3399] -- GPIO Drive and control mode 【Python- data fetch 】 read txt Each line of file generates a list of data vue-countTo Complete operation ( Essence )2020 year 8 month 2 day TypeScript The use of generics ( Essence )2020 year 7 month 12 day webpack Use of common plug-ins 【Python】 read txt file , Gets the specified location data in the specified row airflow Question series 2 —— task keep running Suspended animation