tee command not working as expected (with read and echo)
read -p
is writing it's output to stderr
and echo
is writing to stdout
. stdout
is typically buffered while stderr
is not, and so it's not uncommon to see stderr
things show up before stdout
.
You could have your echo
also go to stderr
if you like by doing echo "string" >&2
or you could run it in the unbuffer
command or similar tools if you have them available