Originally Posted by arizonagroovejet
As far as I'm aware the answer is No.
What you could do though is write the output of the mysql command to a different file, then cat the contents of that to the file output.
mysql -t -h localhost -u user -p=password <queryfile> $foo
cat $foo > output
I'm not sure whether using cat would take an exclusive lock on its output file, so it may still be possible to get an incomplete file if accessed while cat was still running.
( edit: just tried it by doing a
yes | cat - >/tmp/yes.out &
and the redirection does not
lock the output file)
'mv' might be a better choice than cat as it's a more atomic operation and as long as it's moving within the same filesystem wouldn't require the extra copying of data.
mysql -t -h localhost -u user -p=password <queryfile> $foo \
&& mv $foo output
Also note the use of && to only move on success of the mysql command.
disclaimer: I've not played with mysql, so I don't know whether it returns 0 on success or not, but it gives you something more to think on.