I am trying to make
a bunch of files in my directory, but the files are generating ~200 lines of errors, so they fly past my terminal screen too quickly and I have to scroll up to read them.
I'd like to pipe the output that displays on the screen to a pager that will let me read the errors starting at the beginning. But when I try
make | less
less
does not display the beginning of the output - it displays the end of the output that's usually piped to the screen, and then tells me the output is 1 line long. When I try typing Gg
, the only line on the screen is the line of the makefile that executed, and the regular screen output disappears.
Am I using less
incorrectly? I haven't really ever used it before, and I'm having similar problems with something like, sh myscript.sh | less
where it doesn't immediately display the beginning of the output file.
Now you can hit ctrl + c and only less will receive it, letting you use less on a pipe just like you would on a log-file or other growing file.
In Linux, for redirecting output to a file, utilize the ”>” and ”>>” redirection operators or the top command. Redirection allows you to save or redirect the output of a command in another file on your system. You can use it to save the outputs and use them later for different purposes.
You can make it do so by using the pipe character '|'. Pipe is used to combine two or more commands, and in this, the output of one command acts as input to another command, and this command's output may act as input to the next command and so on.
The > symbol is used to redirect output by taking the output from the command on the left and passing as input to the file on the right.
The errors from make
appear on the standard error stream (stderr
in C), which is not redirected by normal pipes. If you want to have it redirected to less
as well, you need either make |& less
(csh, etc.) or make 2>&1 | less
(sh, bash, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With