These are the commands:
$ echo $LINE
$ echo TEXT
TEXT
$ echo TEXT | read LINE
$ echo $LINE
$
I would expect "echo "$LINE" to return "TEXT", but its empty. Any ideas?
These are the commands:
$ echo $LINE
$ echo TEXT
TEXT
$ echo TEXT | read LINE
$ echo $LINE
$
I would expect "echo "$LINE" to return "TEXT", but its empty. Any ideas?
Pipes create a subshell, and a variable created in a subshell does not exist in the main environment.
You can do:
$ read line < <(echo 'my text')
$ echo "$line"
my text