Tail - only show matched phrase
I am tailing a log file with
Code:
tail -f /var/log/messages -n 200 I plan to have two windows - one with the specific watch and one with the complete tail. When the specific watch gets a hit, I can switch to the full tail and see what happened before the event, but without going blind watching the log files and trying to catch the event. Guess I'm after a hybrid tail/grep... Is there such a beast? Linux version is embedded into an Axis single board CPU: BusyBox v0.60.5 (2005.09.26-02:02+0000) Built-in shell (ash) Thanks, Cheers, Critcho. |
hi if you man grep i think option -B will give you what you need.
|
Have you looked at the swatch application?
|
Thanks for the suggestions, looks like this version of Linux doesn't like either of those options:
Code:
[root@AxisProduct /var/log]29054# grep Next step I guess is a small batch file to grep the file every 5 seconds.... |
Well, yes, you'd need to install swatch from, e.g., SourceForge, before you could use it.
You're using "BusyBox V0.6.50" for this? I thought BusyBox was primarily for use in embedded systems, where memory was really limited, and I wouldn't have thought that any windowing system would/could run with only BusyBox/ |
Yup, this is on a small platform on an embedded Single Board Computer. I'm watching the log via a telnet session from my PC. Installing software isn't really an option I guess.
|
Quote:
Code:
tail -n /var/log/messages -n 200 | grep <what-ever> You can also use awk to cat a specific pattern you are looking for. Tux, |
Working OK with a script, not the neatest output but it does the job...
Code:
while true Guess that's the way it happens when you're a programmer - if it doesn't exist, make it yourself! |
Quote:
Thanks Tux, easy when you know how! |
Quote:
|
Yeah, I knew about pipe, just wasn't sure if those two could be combined, because tail has a continual output, and grep is a one-shot command.....
|
Quote:
Tux, |
Ah, I see what you're saying. Take a look at the difference between "tail" and "tail -f".
|
Quote:
Tux, |
All times are GMT -5. The time now is 08:16 AM. |