I have a trivial script which tails multiple files by
spawning a 'tail' process for each file and duping the
output into one file descriptor which is then tailed:
for f in $*; do
tail -1f $f >&3 &
done
exec <&3
tail -f
This works fine under Sun ksh, but I've just tried to run
it now with Bash under Linux 2.4.16, only to have each
command using file descriptor 3 fail with a
'Bad file descriptor'
error.
This has caught me completely unawares. The bash manpage
says that
"If the digits in word do not specify a file descriptor open
for output, a redirection error occurs"
How do I open file descriptor 3 for output? Or, if I do
something like
tail -1f file > /dev/null &
how can I find out what file descriptor is opened so I can
direct the output of further tail commands to the same
descriptor? What's the magic that bash needs to be able to
do something like this?
Many thanks,
Brad