tags:

views:

115

answers:

1

I have a program that spits out both standard error and standard out, and I want to run my pager less on the standard error, but ignore standard out. How do I do that?

Update:

That's it ... I didn't want to lose stdout ... just keep it out of pager

program 2>&1 >log | less

then later

less log
+1  A: 

You could try redirecting standard out to /dev/null, but redirecting standard error to where standard out used to go.

Example in ksh/bash:

program 2>&1 >/dev/null | less

Here the redirection 2>&1, which sets file descriptor 2 (stderr) to point to the same stream as file descriptor 1 (stdout), gets evaluated before the redirection >/dev/null , which sets file descriptor 1 to point to /dev/null. The effect is that what you write to stderr gets sent to stdout, and what you write to stdout gets thrown away.

crosstalk