Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Question - Redirecting All Output

Status
Not open for further replies.

Einstein47

Programmer
Nov 29, 2001
737
US
I know I've seen this before, but since I didn't write it down I have forgotten.

What do I put in a file to redirect all of the stdout to a particular file? I know that I could just put script > stdout.txt but I would rather have the output destination in the script.

Thanks in advance, Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
in your script
{
# your script here
} > output.txt Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Hi

You can also use exec :

exec 3>&1 1>stdout.txt # Save and redirect stdout
. . . . . . . .
exec 1>&3 3>&- # Restor stdout


Jean Pierre.
 
Thanks to both of you - that is exactly what I was wanting.

:) Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top