Date: Wed, 7 Feb 2001 22:53:03 +0100 From: Stijn Hoop <stijn@win.tue.nl> To: freebsd-questions@freebsd.org Subject: read in /bin/sh & pipes [was Re: sed & awk help...?!] Message-ID: <20010207225303.B12534@pcwin002.win.tue.nl> In-Reply-To: <01020804390900.25931@FreeBSD.mine.nu>; from skywizard@time.net.my on Thu, Feb 08, 2001 at 04:36:07AM %2B0800 References: <054F7DAA9E54D311AD090008C74CE9BD01F1E94E@exchange.panasonicfa.com> <01020804390900.25931@FreeBSD.mine.nu>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, This is not really related to the original problem, but is more of a general /bin/sh question. On Thu, Feb 08, 2001 at 04:36:07AM +0800, Ariff Abdullah wrote: > #!/bin/sh > while read a b c ; do > echo "==> line is: $a $b $c" > if [ "$a" = "$b" ]; then > echo " $c" > fi > done < /where/is/the/file/it/should/read Looks nice, haven't tested it. But when I saw this I tried to experiment with parsing stdin with read. Here's a transcript: $ unset bla $ read bla; echo $bla dsa <-- typed by me dsa ok, works as expected, BUT: $ unset bla $ echo dsa | read bla; echo $bla [empty line echo'd] hmm.... doesn't work without a tty? $ unset bla $ echo dsa > tmp.txt; read bla < tmp.txt; echo $bla dsa eh..... why's that? Can't do it with a pipe, but can do from a file? Beats me... Can anyone enlighten me as to why this behavior occurs? --Stijn -- If today is the first day of the rest of your life, what the hell was yesterday? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010207225303.B12534>