为什么 `xargs head` 打印文件名?
Why `xargs head` print filename?
给定两个文件,
a.txt
内容是:A1
,b.txt
内容是:B1
同时执行printf "a.txt\nb.txt" | xargs head -1
、
希望输出
A1
B1
但它输出
==> a.txt <==
A1
==> b.txt <==
B1
为什么输出文件名?
以及如何禁用文件名的输出?
head
正在使用多个参数执行。这会导致输出文件名。来自 head man page:
With more than one FILE, precede each with a header giving the file
name.
可以使用 --quiet
选项抑制 header:
printf "a.txt\nb.txt" | xargs head -1 --quiet
给定两个文件,
a.txt
内容是:A1
,b.txt
内容是:B1
同时执行printf "a.txt\nb.txt" | xargs head -1
、
希望输出
A1
B1
但它输出
==> a.txt <==
A1
==> b.txt <==
B1
为什么输出文件名? 以及如何禁用文件名的输出?
head
正在使用多个参数执行。这会导致输出文件名。来自 head man page:
With more than one FILE, precede each with a header giving the file name.
可以使用 --quiet
选项抑制 header:
printf "a.txt\nb.txt" | xargs head -1 --quiet