1. All three commands can be used to make the preceding output a subsequent input.
2. They have different processing methods for the previous output.
Find. -name "*.sh"-exec cat {} \;
Find. -name "*.sh" |cat
Find. -name "*.sh" |xargs Cat
Example one:
[email protected] temp]# cat ex.sh a.txtb.txtc.txtd.txt5. Txt[[email protected] temp]# find.-name"ex.sh"-exec Cat {} \;a.txtb.txtc.txtd.txt5. Txt[[email protected] temp]# find.-name"ex.sh"|Cat./Ex.sh[[email protected] temp]# find.-name"ex.sh"|Xargs cata.txtb.txtc.txtd.txt5. Txt[[email protected] temp]#
Example two:
[[email protected] django]# find. -name"*.py"./siteone/blog/models.py./siteone/blog/__init__.py./siteone/blog/migrations/__init__.py./siteone/blog/tests.py./siteone/blog/views.py./siteone/blog/admin.py./siteone/siteone/urls.py./siteone/siteone/__init__.py./siteone/siteone/settings.py./siteone/siteone/wsgi.py./siteone/Manage.py[[email protected] django]# find.-name"*.py"-exec echo {} \;./siteone/blog/models.py./siteone/blog/__init__.py./siteone/blog/migrations/__init__.py./siteone/blog/tests.py./siteone/blog/views.py./siteone/blog/admin.py./siteone/siteone/urls.py./siteone/siteone/__init__.py./siteone/siteone/settings.py./siteone/siteone/wsgi.py./siteone/Manage.py[[email protected] django]# find.-name"*.py"|echo [[email protected] django]# find.-name"*.py"|Xargs Echo./siteone/blog/models.py./siteone/blog/__init__.py./siteone/blog/migrations/__init__.py./siteone/blog/tests.py. /siteone/blog/views.py./siteone/blog/admin.py./siteone/siteone/urls.py./siteone/siteone/__init__.py./siteone/ siteone/settings.py./siteone/siteone/wsgi.py./siteone/Manage.py[[email protected] django]#
Summarize:
EXEC executes a command on each of the files found by find.
Xargs is the argument that divides all the found filenames into one parameter and passes them to the command
A pipe symbol that is not Xargs is the standard output of the preceding standard, which is the normal input for the following command
The pipe character with Xargs is the parameter of the previous standard output, as the following command
Find parameter exec, pipe character |, Xargs difference