更好地理解 xargs [英] To understand xargs better
问题描述
我想了解Rampion 的代码:
I want to understand the use of xargs man
in Rampion's code:
screen -t man /bin/sh -c 'xargs man || read'
感谢 Rampion:我们不需要猫!
为什么我们需要在命令中使用 xargs
?
Why do we need xargs
in the command?
我理解 xargs
部分如下
- 对 xargs 无所谓
- xargs 列出 man 命令
我有一个想法,xargs 会生成一个命令列表.例如,
I have had an idea that xargs makes a list of commands. For instance,
find . -type f -print0 | xargs -0 grep masi
与命令列表相同:
find fileA AND grep masi in it
find fileB AND grep masi in it
and so on for fileC, fileD, ...
推荐答案
不,我什么都不cat
.运行命令后,我将获取任何输入.cat
在这里实际上是无关紧要的,所以让我们忽略它.
No, I don't cat
nothing. I cat whatever input I get after I run the command. cat
is actually extraneous here, so let's ignore it.
xargs man
等待用户输入.这是必要的.由于在您从中获取的脚本中,我无法在创建窗口之前粘贴 man 的参数.所以在窗口中运行的命令需要等待我给它一些东西,然后它才会尝试运行 man.
xargs man
waits on user input. Which is necessary. Since in the script you grabbed that from, I can't paste in the argument for man until after I create the window. So the command that runs in the window needs to wait for me to give it something, before it tries to run man.
如果我们只是运行 screen/bin/sh -d 'man ||阅读'
,它总是会抱怨你想要什么手册页?"因为我们从来没有说过.
If we just ran screen /bin/sh -d 'man || read'
, it would always complain "What manual page do you want?" since we never told it.
这篇关于更好地理解 xargs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!