Redirect all output to a log file

When you build a program or execute a shell command, the messages are often outputted to both standard output and standard error. If you want to send all ‘printf’ to a log file, use the following command:

make > make.log 2>&1

“2>&1”  is the part that redirects standard error to standard out, allowing you to capture all messages.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress. We also use affiliate links in articles to earn commissions if you make a purchase after clicking on those links.

2 Replies to “Redirect all output to a log file”

  1. Also we can use : make 2>& | tee make.log
    This will make sure you see the output both on terminal as well as on the File. Most of the times you need not look into the file to check if its successfully compiled.

Leave a Reply

Your email address will not be published. Required fields are marked *

Boardcon LGA3576 Rockchip RK3576 System-on-Module designed for AI and IoT applications
Boardcon LGA3576 Rockchip RK3576 System-on-Module designed for AI and IoT applications