Does'nt Make Out mean something else in the US :shock:
When compiling software, don't just type 'make' and let run! You will never be able to catch your errors!
Do:
and then doCode:make > Make.Out &
That will continuously show you the end of your Make.Out file, giving you the chance to go "Hey, what was that?!?", hitCode:tail -f Make.Out
and not interrupt your compile.Code:^C, grep Make.Out
Does'nt Make Out mean something else in the US :shock:
I believe Make outputs errors to STDERR, so your code should be:
Code:make 2> make.out & tail -f make.out
Oh, that's what she meant when she asked me if I want to make out. :lol:
heh :lol:Originally Posted by janne_oksanen
Make tees the messages to STDOUT. of course, you could send the output anywhere;
Code:make >> InsaneAmountOfData.txt &;tail -f !$
Even better, try:
This will create a file, "output-barrel.full.of.errors.txt", containing the output of make. And, it will automatically tail the output of make as it comes. "tee" does both, tail and output to a file.Code:make | tee output-barrel.full.of.errors.txt
Enjoy!
If you want both stderr & stdout, you need to use '&>' as the redirector, not '2>' or '>', which only redirect stderr and stdout, respectively.
0: standard input
1: standard output
2: standard error
I thought a more detailed explanation of this could be useful to some, so here goes:
If you want to save the output of a command into a text file, you use >. An example to redirect the output of ls to foo.txt:
ls > foo.txt
IMPORTANT: If there is no file called foo.txt, it will be created - without a warning.
If, however, there already is a file called foo.txt, it will be overwritten - also without a warning. This means the date which it contained at first will be lost.
Next we have the >> redirector, which does exactly the same as >, except that it appends a file. For those who aren't familiar with English (I'm not, and I remember it being a PITA for me to understand what they meant with 'append' back when I learned about redirection), this means that in case foo.txt already exists, the data it contains won't be overwritten - the new data will just be added ('appended') to the end of foo.txt
As some might know, not all data which an application outputs into a terminal (or a text file) is normal output (aka stdout, or standard output), there are also error messages (aka stderr, or standard error). To redirect the error messages to a file errormsgs.txt, you use 2>, like this:
appname 2> errormsgs.txt
The 2> redirector can be very useful if you're having a problem with an application: you start it up from a terminal like this:
buggy_application's_name_goes_here 2> /tmp/error.log
and afterwards you include /tmp/error.log in a mail to the application's mailinglist/developer or analyse it yourself.
IMPORTANT: this will just redirect stderr, not stdout.
When you want to report information about a program which isn't behaving correctly like the above example, you'll probably want to redirect the normal output, too.
You can achieve this with 2>& redirector. So a better version of the error-reporting command line above would be this:
buggy_application's_name_goes_here 2>& /tmp/error.log
So now you can redirect stdout and stderr... what's left? standard input (stdin), of course.
You can redirect input from a file using <.
How can this be useful? Well, let's take the first example again:
ls > foo.txt
This just redirects the output from the command ls to foo.txt, but what if we wanted to sort it using the command sort?
Well if you read this topic, you know how you can pipeline the data (like with the 'tee' example), like this:
ls | sort > foo.txt
Here's an alternative to the command above:
ls > foo.txt
sort < foo.txt > sorted_foo.txt
In this case, using the < redirector would be pretty dumb of course, since it would change a one-liner to two lines of code, and IMHO the second command is less clear.
However, I think you now understand how < works, which is the most important. The truth is I just don't know a useful way to use < at the moment - I've never used it even
Oh wait, I remember as "useful" thing you can do with the stdin redirector: maybe you want to mail yourself a logfile of a remote system periodically, for example an SSH access log. You can let this happen periodically using 'cron' if you pass this command to cron: mail //blahblah subject here + your e-mail etc, I don't know the correct syntax for 'mail' out of the top of my head// < /var/log/ssh.log
Well, or something like that at least - I don't use 'mail', and I don't have a manual page for it installed, but I do know you can send mails with it using the input redirector.
For those who want to know more, chapter 16 of the Advanced Bash-Scripting Guide covers redirection in more detail (you can find it on TLDP).
Bookmarks