测试人社区

【求助】find . -name "pom.xml" | xargs -I {} 命令中的I是什么作用?

Mac环境下,已使用搜索,查看help,不太理解,说是replace用的。帮助行命令如下,希望大佬给解答一下:

Execute utility for each input line, replacing one or more occurrences of replstr in up to replacements (or 5 if no -R
             flag is specified) arguments to utility with the entire line of input.  The resulting arguments, after replacement is
             done, will not be allowed to grow beyond 255 bytes; this is implemented by concatenating as much of the argument contain-
             ing replstr as possible, to the constructed arguments to utility, up to 255 bytes.  The 255 byte limit does not apply to
             arguments to utility which do not contain replstr, and furthermore, no replacement will be done on utility itself.
             Implies -x.

请问这个find . -name "pom.xml" | xargs -I {} 命令中的 -I 是什么作用?

表示卡位符,可以在后面的命令中进行替换,用来表示前面读取的每一行

seveniruby:~ seveniruby$ echo -e "1\n2\n3" | xargs -I {} echo https://ceshiren.com/t/topic/{}
https://ceshiren.com/t/topic/1
https://ceshiren.com/t/topic/2
https://ceshiren.com/t/topic/3

明白了,谢谢老师。