I procrastinated to look up this for such a long time.. today was enough. What I want to achieve is reading a line from stdin and split it among several variables, naively I'd do:
$ echo "A BB CCC" | read a b c
$ echo $a $b $c
(no output.) As well explained here the above code doesn't work, but this one does:
$ read a b c < <(echo "A BB CCC")
$ echo $a $b $c
A BB CCC
as a hint, <(cmds) is called process substitution.
Showing posts with label Bash scripting. Show all posts
Showing posts with label Bash scripting. Show all posts
Subscribe to:
Posts (Atom)