Linux command Brief introduction of Xargs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.