我试图让bash处理来自stdin的数据,但是没有运气.我的意思是以下工作:
echo "hello world" | test=($(< /dev/stdin)); echo test=$test
test=
echo "hello world" | read test; echo test=$test
test=
echo "hello world" | test=`cat`; echo test=$test
test=
Run Code Online (Sandbox Code Playgroud)
我想要输出的地方test=hello world.我试过把""引号括起来"$test"也不起作用.
我试图理解这两个相似命令之间的差异.
aa=$(foo | bar | head -1)
read aa < <(foo | bar | head -1)
Run Code Online (Sandbox Code Playgroud)
<()需要#!/bin/bash,但这会让它变慢吗?bash或sh流程?我希望使用具有最佳性能的命令.