Bash Shell管道$()vs direct命令
新手到shell编程 要运行命令并将其输出放入变量中,我们使用:Bash Shell管道$()vs direct命令,bash,redirect,pipe,Bash,Redirect,Pipe,新手到shell编程 要运行命令并将其输出放入变量中,我们使用: var=$(command) 命令和$(命令)之间的重定向管道有什么区别。 作品: 错误 在子shell中执行,然后将输出放在原始命令中。 所以,基本上你是在做这件事 $(command) | while read line # Example result-of-command | while read line # Bash reads 阅读有关命令替代的更多信息,或者将$()想象成一个shell
var=$(command)
命令和$(命令)之间的重定向管道有什么区别。
作品:
错误
在子shell中执行,然后将输出放在原始命令中。
所以,基本上你是在做这件事
$(command) | while read line # Example
result-of-command | while read line # Bash reads
阅读有关命令替代的更多信息,或者将$()想象成一个shell,您可以在其中键入内容
$(command) | while read line
do
echo $line
done
$(command) | while read line # Example
result-of-command | while read line # Bash reads