2>&1 and understanding other shell script’s idioms

Image of a terminal prompt

If you are a system administrator, or someone that just writes shell scripts then every now and again, you’ll want to do output redirection. The ability to redirect the standard output of a command, say grep Intel /proc/cpuinfo to a text file, can simply be performed as such: grep Intel /proc/cpuinfo > textfile.txt. The possibilities are endless. You can use pipes (| ), appends ( >> ) and combinations ( & ). The basics are easy enough to understand, and they will be used every day as a sysadmin, however using the more esoteric of them can be quite a challenge, even for a more seasoned sysadmin.

This article clearly explains how to get to grips with these operands and helps you remember them by teaching the logic.

Read full article

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.