Search This Blog & Internet

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, April 10, 2012

Visualize logs real time in Linux

With the following command you can visualize the logs real time in Linux:

tail -f FILENAME

If you want to filter in real time logs, tail and grep can be combined:

tail -f FILENAME | grep FILTER

Monday, March 26, 2012

Logical AND and OR with grep

I am not that much familiar with Linux and Unix, but I find these commands so helpful when you parse the logs.
To do a logical OR, you can use one of the following commands:
grep -i -E "Var1|Var2" FILENAME 

awk '/Var1/ || /Var2/' FILENAME

To do a logical AND, you can use the following command:
grep VAR1 FILENAME | grep VAR2 | grep VAR3

awk '/Var1/ && /Var2/' FILENAME