Xargs I Parameters

Source: Internet
Author: User
Xargs and find are often used in combination to perform file operations. When you delete logs, you just get used to deleting them, such as # find. -typef-name *. log | xargsrm-rf * deletes the file ending with log. If I want to move or copy the file, I need to replace it with parameters. Xargs-I parameters or-I parameters can be used together with {} to perform the xargs and FindFile operations are often performed in combination. Usually, you are used to deleting logs, such as # find.-type f-name "*. log" | xargs Rm-Rf * deletes the file ending with log. If I want to move or copy the file, I need to use parameters instead. The xargs-I parameter or-I parameter can be used together with {} to perform file operations. -I replace-s Tr
Replace occurre NcEs of replace-str in the initial-arguments with names read from standard input. LsO, unquot EdBlanks do not terminate
Input items; instead the separator is the newline character. Implies-x and-L 1.

-- Replace [= replace-str],-I [replace-str]
This option is a synonym for-Ireplace-str if replace-str is specified, and for-I {} otherwise. This option is depre CatEd; use-I instead.
Man is still not familiar with it. He wrote down my understanding through examples. ############## Files in the operated directory ################# [root @ test05 AB] # ls
1kk. Zip3kk.zip 5kk.zip B .rar d.rar f.rar h.rar j.rar mini.txt ni.txt
2kk.zip 4kk.zip a.rar c.rar e.rar g.rar I .rar k.rar nii.txt ################## using I parameters ######### #########
[Root @ test05 AB] # find.-type f-name "*. txt" | xargs-I Cp{}/Tmp/k/
[Root @ test05 AB] # ls ../k/
Mini.txt nii.txt ni.txt
[Root @ test05 AB] #################### use the I parameter ########### #####
[Root @ test05 AB] # find.-type f-name "*. txt" | xargs-I {} cp {}/tmp/n/
[Root @ test05 AB] # ls ../n/
The result of mini.txt nii.txt is displayed. The added-I parameter can replace the standard output content in the pipeline directly with {}. The added-I parameter must specify the replacement character in advance.
 
Related Article

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.