Created
December 11, 2012 05:18
-
-
Save yegle/4256080 to your computer and use it in GitHub Desktop.
bash read varaible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# FAIL! | |
echo a| read i | |
echo $i | |
# WORKS | |
read i <<<$(echo a) | |
echo $i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bash 4.2 有
lastpipe
选项,开启了就和 ksh 一样了,管道的最后一部分在当前 shell 运行。