Pages

Friday, September 17, 2010

GREP - Shell Script

What is GREP ?
Global Regular Expression Parser.

What is the purpose of GREP ?
Say,
the command
free -m
gives,
             total       used       free     shared    buffers     cached
Mem:          1957       1810        146          0         48        405
-/+ buffers/cache:       1356        600
Swap:         3812         99       3712

Now to get the row Mem: alone, we use,


 free -m | grep Mem:


which gives,


Mem:          1957       1775        181          0         48        406

as Output.


if you put option as -q,it is silent grep, (i.e) the output wont be echoed in console

No comments:

Post a Comment