Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jan 2000 12:38:27 -0500
From:      "Crist J. Clark" <cjc@cc942873-a.ewndsr1.nj.home.com>
To:        freebsd-questions@FreeBSD.org
Subject:   sh(1) Messing with My Mind
Message-ID:  <20000120123827.A72914@cc942873-a.ewndsr1.nj.home.com>

next in thread | raw e-mail | index | archive | help
I think my mind is broken or something. This is really confusing me. I
must be missing or forgetting something obvious.

I was writing a sh-script that ran some stuff through awk and I wanted
to drop the results in some shell variables, so I piped  the awk
output to a read command. But it would not work. The sh-builtin "read"
seems to have muddled my thoughts this morning. Why does this happen:

$ echo 3 | read NUM
$ echo $NUM  

$ read NUM
3
$ echo $NUM
3
$ echo "TEST" | read STR
$ echo $STR

$ echo "TEST" > afile.txt
$ read STR < afile.txt
$ echo $STR
TEST
$

Where the second read shows my keyboard input working, and the third
shows a successful redirect to read from a file. Why does it look like
read won't read from a piped stdin? I could swear I used to do this
all of the time.
-- 
Crist J. Clark                           cjclark@home.com


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?20000120123827.A72914>