源码

linux – 从管道中将值读入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=

我希望输出为test = hello world.我已经尝试在“$test”周围加上“引号”,这也不起作用.

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/linux-congguandaozhongjiangzhidurushellbianliang.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 16, 2019 at 05:49 下午

热评文章