Closing only stderr in a sh(1) command.

Jonathan I. Kamens jik at athena.mit.edu
Wed May 2 14:22:44 AEST 1990


In article <1605 at dinl.mmc.UUCP>, noren at dinl.uucp (Charles Noren) writes:
|> What I want to do is:
|> 
|>    ls *.o | some-util
|> 
|> so that if there is no *.o files, it will not be reported.
|> In other words, can I close only stderr (or redirect it to
|> /dev/null) while keeping stdin and stdout unaffected?

  May I humbly suggest that you RTFM before posting a question like this
to the net?  I'm fairly certain that the man page sh(1) talks about
using the num>file syntax to redirect a specific file descriptor
somewhere.  In this particular case, you might try:

    ls *.o 2>/dev/null | some-util

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list