gpt4 book ai didi

Will `ls . | grep test &` run both commands in the background, or only the last one?(威尔。|grep test&`两个命令都在后台运行,还是只运行最后一个?)

转载 作者:bug小助手 更新时间:2023-10-25 19:50:09 24 4
gpt4 key购买 nike



If I run ls . | grep test & in a shell which consists of two commands, the output of one being piped into the other, will both commands run in the background or only the last one (grep)?

如果我运行ls。|grep测试&在一个由两个命令组成的外壳中,其中一个命令的输出通过管道传输到另一个命令中,这两个命令是在后台运行还是只在最后一个(Grep)运行?


I've tried running the command in a shell while monitoring processes. I can't deduce anything from the result.

我曾尝试在监控进程时在外壳中运行该命令。我不能从结果中推断出任何东西。


更多回答

the standard says that this case is: complete_command comprising list separator_op, where separator_op is & and list is an and_or which is pipeline

该标准说,这种情况是:Complete_Command包括列表分隔符_op,其中分隔符_op是&,列表是一个AND_OR,它是流水线

优秀答案推荐

It runs against the entire command.

它与整个命令背道而驰。


That is it runs against ls . | grep test and not against ls . or grep test.

这就是它与ls的竞争。|grep测试,而不是针对ls。或GREP测试。


The pipe created by the shell is still open, even in the back ground and the ls . command is still sending data through it.

由贝壳创造的管道仍然是开放的,即使是在幕后和地下。指挥部仍在通过它发送数据。


Perhaps, (sleep 5 ; ls .) | grep test & may give you a better understanding.

也许,(睡眠5;ls.)|grep测试&可能会让你更好地理解。


更多回答

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