Brian Chrzanowski



Shell Things

I'm making this page because every single time I Google for "How to do X in Bash", I literally get a crappy page with ads that doesn't actually answer my question. So, maybe this page will answer this for me and for others.

Redirection

How do I redirect stdout to a file?

command > filename

How do I redirect stderr to a file?

command 2>filename

How do I redirect both to a file?

# supported by all shells
command > filename 2>&1

# supported only by bash and zsh
command &> filename