I have two shell scripts, one that serves as the main \"program\" and another that serves as a \"library.\"
In several places in the \"program,\" I\'ll do something
Open /dev/tty
on another FD.
exec 0< /dev/null
exec 1> /dev/null
exec 2> /dev/null
exec 3> /dev/tty
echo 'Hello, World!' >&3
You can write directly to /dev/tty
each time you want to write to the terminal:
echo "hello world" > /dev/tty
For a small example:
$ cat writer.sh
#!/bin/sh
echo "standard output"
echo "standard error" >&2
echo "direct to terminal" > /dev/tty
$ ./writer.sh > /tmp/out 2> /tmp/err
direct to terminal
$ cat /tmp/out
standard output
$ cat /tmp/err
standard error
$