Search code examples
c++linuxubuntuhead

viewing top lines of big error outputs


During compilation process many errors are thrown on the screen. To start resolving them I need to scroll up 3, 4 pages. I tried doing head on them but they still came on the terminal.

g++ -std=c++0x testCoverDownloader.cpp -I /usr/include/QtCore/ -I /usr/include/QtGui 2>&1 | head

how to I just see the top errors first and then scroll down the page? The code above cuts the output to show the top 10 lines. What I want is all errors but from the start so that I dont need to scroll upwards


Solution

  • If you use vim you could try <your compile statement> 2>&1 | vim - That should pipe STDERR and STDOUT to vim for viewing.

    EDIT: Added in @joachim pilberg's comment to provide a more accurate answer:

    The important part is the redirection part: Error from the compiler is put on stderr. To pipe it to head, a viewer like more or less or even an editor like vim, you need to redirect stderr to stdout. This is what is done with the &2>1 (or more correctly 2>&1). See the manual page of your shell for more information about redirection.