Today, I begin to summarize the commands I have learned, and I mainly learn to use them. Let's summarize the next xargs today.
Xargs a filter that passes command-line arguments to other commands.
Options
-N Specify how many columns per row
-I replaces previous content with {}
-D Specify delimiter
-0 with the-print0 of find to handle files with a blank name
Usage examples:
1-n usage
[email protected] tmp]# cat Sed.txt
Stu1
123
Stu2
222
[Email protected] tmp]# Xargs <sed.txt
STU1 123 STU2 222
[Email protected] tmp]# Xargs-n2<sed.txt
STU1 123
STU2 222
[Email protected] tmp]# echo stu{1..3}|xargs-n1
Stu1
Stu2
Stu3
2-i usage
Find files and copy to/tmp
[Email protected] tmp]# find/etc-type f-name "passwd" |xargs-i CP {}/tmp
Usage
[Email protected] tmp]# echo aaaxdddxccc|xargs-d x-n1
Aaa
Ddd
Ccc
4-0 (0) usage
[[email protected] tmp]# touch "a B.txt"
[Email protected] tmp]# find-name ". SSS"-print0|xargs-0 ls-l
-rw-r--r--1 root root 0 June 09:19./a B.sss
Because the name has a space, all with Xargs can only be processed with this method, if using-exec, the example is as follows:
[Email protected] tmp]# find-name ". SSS"-exec ls-l {} \;
-rw-r--r--1 root root 0 June 09:19./a B.sss
Linux command Brief introduction of Xargs