相关疑难解决方法(0)

从管道中将值读入shell变量

我试图让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"也不起作用.

linux bash pipe

193
推荐指数
12
解决办法
30万
查看次数

标签 统计

bash ×1

linux ×1

pipe ×1