Operating System - HP-UX
1830233 Members
1931 Online
109999 Solutions
New Discussion

STDOUT and STDERR redirection within a script

 
SOLVED
Go to solution
Patrick Ware_1
Super Advisor

STDOUT and STDERR redirection within a script

Hello all,

I have a for loop executing in a script that I want to redirect STDOUT to screen and to file, while directing STDERR to the bit bucket. Here is the general sentax of what I'm doing:

for i in thingy
do
some_command ${i}
done 1>&1 | tee ${LOGFILE} 2> /dev/null

What I am finding is that STDOUT is going to the logfile and to screen, while STDERR is still going to the screen only. How do I totally get rid of STDERR? I don't want it going to screen or file.

Thanks in advance!
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: STDOUT and STDERR redirection within a script

Hi Patrick:

You want:

...
done 2> /dev/null | tee ${LOGFILE}

Regards!

...JRF...

Patrick Ware_1
Super Advisor

Re: STDOUT and STDERR redirection within a script

That worked perfectly. Thank you.