echo -en "one\ntwo\nthree" | while read VALUE
do
echo "${VALUE}"
done
This will print one and two, but not three. The last line is IGNORED because it lacks a newline. This makes it hard to use sh for things like CGI scripting; you have to add a newline with sed or something. How can I coerce read into reading the last line?
I haven't changed the value of IFS. What version of echo do you have? The version I use implements the '-n' flag, which prevents it from printing the final newline, like so:
# echo -n "Hello"
hello#
If yours does not have -n, the example won't fail.
It's just an example. The real problem is getting bash to read POST input from the CGI interface, which is fed into stdin and also has no trailing newline. Right now I have to do crazy manipulations with sed and exec. With enough work I can probably find less crazy ways, but all of them involve launching a new process instead of using a builtin, which annoys me to no end.