a.tx-6ren">
gpt4 book ai didi

linux - 为什么 `xargs head` 打印文件名?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:45:13 25 4
gpt4 key购买 nike

给定两个文件,a.txt内容为:A1b.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

关于linux - 为什么 `xargs head` 打印文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48186395/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com