小编Bob*_*421的帖子

为什么带有命令替换 herestring 的 Bash 'while' 读取循环不读取整个输入?

看看这个非常基本的 Bash 脚本:

#!/bin/bash
while read l
do
  echo $l
  echo "next one"
done <<< $(ps aux)
Run Code Online (Sandbox Code Playgroud)

我的计算机上有多个进程,该ps aux命令在终端中运行良好。

我在循环中只得到一次迭代,ps命令输出在同一行给出。为什么它不能按预期工作?

bash command-substitution read here-string

3
推荐指数
1
解决办法
1389
查看次数

标签 统计

bash ×1

command-substitution ×1

here-string ×1

read ×1