You can use ggrep command to print or grep a certain number of lines before or after a particular search string / pattern from a file.
This will be quite useful when you know a search string / pattern, for eg : ORA-00257: archiver error. Connect internal only. You might want to see from when onwards this error has been reported in alert log. The log might be very huge , a vi / tail might be time consuming in this case. Use the below command.
/usr/sfw/bin/ggrep -A 5 -B 5 'ORA-19815:' alert_idckf.log > 1 |
Here
-A 5 and -B 5 , where 5 stands for number of lines before and after the search string "ORA-19815:'"
/usr/sfw/bin/ggrep -B 10 'ORA-19815: WARNING:
db_recovery_file_dest_size of 26754416640 bytes is 100.00% used'
alert_idckf.log > 1
|
Here , the search is only for printing 10 lines after the search string 'ORA-19815: WARNING: db_recovery_file_dest_size of 26754416640 bytes is 100.00% used' from the file alert_idckf.log. The output is redirected to 1, which can be viewed.
0 comments:
Post a Comment