Hi,
I was playing with shell scripting, when a strange thing happened. I need someone to explain it.
I have a file 'infile', contents:
line one
line2
third line
last
a test script test.sh, contents:
read var1
echo $var1
i executed:
cat infile | ./test.sh
output was
line one
Then I did:
cat infile | read var1
echo $var1
Result: a blank line.
I even tried
cat infile | read var1; echo $var1;
same result.
why does this happen?