Skip to content

Instantly share code, notes, and snippets.

@yegle
Created December 11, 2012 05:18
Show Gist options
  • Save yegle/4256080 to your computer and use it in GitHub Desktop.
Save yegle/4256080 to your computer and use it in GitHub Desktop.
bash read varaible
#!/bin/bash
# FAIL!
echo a| read i
echo $i
# WORKS
read i <<<$(echo a)
echo $i
@weynhamz
Copy link

Bash 4.2 有 lastpipe 选项,开启了就和 ksh 一样了,管道的最后一部分在当前 shell 运行。

shopt -s lastpipe

不小心看到了,进来发发牢骚。另外,竟然不能修改评论,你能修改的话,把上一条的格式调整下吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment