看看这个非常基本的 Bash 脚本:
#!/bin/bash while read l do echo $l echo "next one" done <<< $(ps aux)
我的计算机上有多个进程,该ps aux命令在终端中运行良好。
ps aux
我在循环中只得到一次迭代,ps命令输出在同一行给出。为什么它不能按预期工作?
ps
bash command-substitution read here-string
bash ×1
command-substitution ×1
here-string ×1
read ×1