|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: [PLUG] changing stdout in a script
|
Jeff Abrahamson <jeff@purple.com>:
> Can a shell script change where stdout goes?
>
> I have a shell script that creates a directory. I would like to have
> echo and all other instances of output to stdout go to a file in this
> directory.
>
> Of course, I could do this with two scripts, one of which is a
> wrapper. Does anyone know a way to do this with just one script?
exec >the-file
will redirect the standard output.
If you will want to put it back the way it was later on, you may
exec 3>&1 >the-file
before and
exec 1>&3 3>&-
after.
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|