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
You could try redirecting standard out to /dev/null, but redirecting standard error to where standard out used to go.
Example in ksh/bash:
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.