i am having some trouble locating a way to do what I want.
I want to tail and follow a log file, which is easy, just tail -f /somelogfile.
Then rather than see the whole lot I want to pick bits out, for example if it was a BB2 and I want to just see posts I could do:
tail -f /some-log-file | grep some-entry
would produce what I want. However, what I want to see is lines that contain either some-entry, or some-other-entry or another-entry
So that I can pick out several types of interesting traffic with out having to have dozens of screens open.
Any one help? The man file implies I can do:
tail -f /some-log-file | grep some-entry |; some-other-entry |; a-third-entry
but this falls down with this bash error:
-bash: syntax error near unexpected token `;'
If you use "|" don't use ";". But that's the other thing. For grep you can use something like this:
tail -F /some/path/some_file | grep "first-entry|second-entry|some other entry"
Yep, that works.
many thanks. I do like the power of the CLI, and the tools available to manipulate large files for interesting things without having to read the lot.
Many thanks for that.
grep [first-entry,second-entry,some other entry]
should work, the "," are like or's inside "[" brackets.
For some reason that seems to confuse grep and I get the whole tail.
I also tried with
tail -f /some-log-file | grep ['first-entry','second-entry','some other entry']
and that produced the same result.
lanrat's option seems to work well, but what I would like to do now is to pipe the output to another logfile so I tried something like this:
tail -f /some_log_file | grep "first_expression|second_expression|third_expression" > /some_other_logfile
but tailing that shows nothing at all.
tail -f /some_log_file | grep -e "first_expression|second_expression|third_expression" > /some_other_logfile
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍