How to use the read command in Bash?

前端 未结 8 1771
执念已碎
执念已碎 2020-12-07 23:54

When I try to use the read command in Bash like this:

echo hello | read str
echo $str

Nothing echoed, while I think str<

8条回答
  •  一向
    一向 (楼主)
    2020-12-08 00:50

    The value disappears since the read command is run in a separate subshell: Bash FAQ 24

提交回复
热议问题