Blog Archives

#Linux : use grep to extract lines around a pattern match

In the text processing toolkit of every sys admin or data scientist out there there is a well known command line utility of which utility is second to none (ok, maybe sed is a strong contender): grep.

So “grepping” has become a known term among developers and it has the same meaning as “googling”, that is find something that matches my query in this file. Grep will return the list of rows matching the specified pattern.

However sometimes it is useful to have some context around the pattern match, especially if we are talking about system logs; in this case grep has a couple of little known flags that are super useful: -A, for after the pattern match, and -B for before.
For example to display 10 lines before and 15 lines after any system log line that contains the word error:

#journalctl --no-pager | grep "error" -A 15 -B 10

#MacOSX : Xlog, Logs As The Desktop Background [OUTDATED]

Ok, this is for sys admin and paranoid people.

If you want see system logging in real time on your desktop there exist an amazing app: Xlog

Here you can see a beautifull screen on how it looks like:

Sadly, Xlog is no longer available in the App Store and stopped working since Mac OS El Capitan.

NOTE: you can set Xlog preferences to start it automatically on login. 😉

NOTE2: you can choose text & background color and transparency.

%d bloggers like this: