I have a log file "Apps.out" of an application for a WebLogic, there is a specific app that sends logs like this to that file:
[YYYY/MM/DD HH:MM:SS][INFO][PATTERN -> Information1]
[YYYY/MM/DD HH:MM:SS][INFO][PATTERN -> Information2]
[YYYY/MM/DD HH:MM:SS][INFO][PATTERN -> Information3]
[YYYY/MM/DD HH:MM:SS][INFO][PATTERN -> Information4]
[YYYY/MM/DD HH:MM:SS][INFO][PATTERN -> Information5]
I can filter this information with: grep ‘PATTERN’ Apps.out
but I want to send this information to a new file (app1.log) and do this progressive just to send the new register on app1.log that matches the PATTERN, is it possible to do it in real-time?
Thank you
2
Answers
You can do it using
tail -f
:nohup bash -c "tail -f Apps.out | grep PATTERN > app1.log" &
This will follow the file as it grows from the moment you start going back 10 lines.
You can change that with
-n
and go back as many lines as wish or read from the start of the file.here is what you can do :
<your_log_file>
as your log fileand
<your_PATTERN>
as you PATTERN