On Fri, 27 Jan 2006, Yuri Karlsbrun wrote:
Hello,
I, probably, need bash-help mailing list, but I could not find it.
The best place is the Usenet news group, comp.unix.shell.
Here is the bash script fragment:
LOG_FILE="./logfile"
...
> $LOG_FILE
That statement will create an empty file if it does not exist, and
truncate it to zero bytes if it does exist.
I supposed that the statement above redirects stdout to the logfile.
But the following 'echo' statement prints on the screen.
To redirect the output of a command:
echo SOMETHING > "$LOG_FILE"
To redirect several commands, enclose them in braces:
{
echo "Today's date:"
date
} > "$LOG_FILE"
The logfile is opened.
If you want all succeeding output to go be redirected, use exec:
exec > "$LOG_FILE"
echo "THIS 'n' THAT" ## <-- This will be sent to "$LOG_FILE"
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash