Friday, April 17, 2015

Directing stdout and stderr

Some interesting syntax I wasn't aware of from this stack overflow thread.


# Send stdout to sample.s, stderr to sample.err
myprogram > sample.s 2> sample.err

# Send both stdout and stderr to sample.s
myprogram &> sample.s # New bash syntax
myprogram > sample.s 2>&1 # Older sh syntax

# Log output, hide errors.
myprogram > sample.s 2> /dev/null

No comments:

Post a Comment