вторник, 5 июля 2011 г.

Shell: following a keyword in a constantly updated file

We can follow a file on the screen with the command:

tail -f /var/myfile


But if we are looking for only some specific keywords we can use the following command:

tail -f /var/myfile | fgrep --color -C 4 'keyword'


Here the "--color" means to highlight the found keyword.
And "-C 4" means to print 4 lines above and below the found keyword.

Комментариев нет:

Отправить комментарий