对于linux命令xargs,Inone的意思是什么?
问题描述:
我已经看到了linux命令xargs的Inone选项,但是我搜索了一下,但没有发现这个选项的含义。 seq 2 | xargs -Inone cat file
Using seq with xargs:对于linux命令xargs,Inone的意思是什么?
答
这是一个巧妙的运用xargs
和seq
避免编写循环。它基本上是等价的:
for i in {1..2}; do
cat file
done
即,将用于从所述seq
命令输出的每一行运行cat file
一次。 -Inone
只是防止xargs
将从seq
读取的值附加到该命令;看到在-I
选项细节xargs
手册页:
-I replace-str
Replace occurrences of replace-str in the initial-ar‐
guments with names read from standard input. Also,
unquoted blanks do not terminate input items; instead
the separator is the newline character. Implies -x
and -L 1.
+2
我不确定我会打电话来避免一个带有多个外部进程的“壳”结构“聪明”。 – chepner
这是'-I [取代-STR]' – franklinsijo
那你谷歌?搜索“man xargs”,手册页是第一次。然后,你RTFM。这是谷歌之前的两倍,当你只是RTFM。也就是说,你直接在你的shell中键入'man xargs'而不是web浏览器。孩子们这些天。 smh –