From owner-freebsd-questions Wed Feb 7 13:53:31 2001 Delivered-To: freebsd-questions@freebsd.org Received: from pcwin002.win.tue.nl (pcwin002.win.tue.nl [131.155.71.72]) by hub.freebsd.org (Postfix) with ESMTP id 8DB8A37B6B2 for ; Wed, 7 Feb 2001 13:53:13 -0800 (PST) Received: (from stijn@localhost) by pcwin002.win.tue.nl (8.11.1/8.11.1) id f17Lr3A14365 for freebsd-questions@freebsd.org; Wed, 7 Feb 2001 22:53:03 +0100 (CET) (envelope-from stijn) Date: Wed, 7 Feb 2001 22:53:03 +0100 From: Stijn Hoop To: freebsd-questions@freebsd.org Subject: read in /bin/sh & pipes [was Re: sed & awk help...?!] Message-ID: <20010207225303.B12534@pcwin002.win.tue.nl> References: <054F7DAA9E54D311AD090008C74CE9BD01F1E94E@exchange.panasonicfa.com> <01020804390900.25931@FreeBSD.mine.nu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <01020804390900.25931@FreeBSD.mine.nu>; from skywizard@time.net.my on Thu, Feb 08, 2001 at 04:36:07AM +0800 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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