![Lead Image © Andrey Lavrushov, 123RF.com Lead Image © Andrey Lavrushov, 123RF.com](/var/ezflow_site/storage/images/archive/2014/24/coming-to-grips-with-grep/po-25540-123rf-andrey_lavrushov_resized.png/106534-1-eng-US/PO-25540-123RF-Andrey_Lavrushov_resized.png_medium.png)
Lead Image © Andrey Lavrushov, 123RF.com
Coming to grips with grep
Patterns
We are all creatures of habit in varying degrees, and I frequently find myself settling into various routines in my job as a sys admin. I have had many a moment in which I lucidly caught myself thinking: "Not this task again! I really need to speed this process up." By simply automating a procedure or ultimately deprecating and condemning it as redundant, I could save a lot of time in the long run.
When I recently spent some time away from the computer monitor, I had a chance to consider what I could use to help automate tasks and to think about the procedures that I face routinely. In the end, I concluded that clever little command lines were the way forward, and in most cases, these could translate into clever little shell scripts.
To increase my efficiency in creating command lines and scripts, I made a conscious decision to start again and effectively go back to basics with some of the core shell commands; that is, I wanted a timely way to improve my understanding of a few key packages so that I wasn't always looking up a parameter or switch and, thus, speed up my ability to automate tasks.
When I typed history
at the prompt, lo and behold, that old favorite grep
stood out as something I use continually throughout my working day. Therefore, in this article, I will dig into some of the history of grep and attempt to help you improve your readily available knowledge, with the aim of being able to solve problems more efficiently and quickly.
Not Such a Bad Pilot
As most sys admins soon discover, one of the heroes of the Linux command line is the grep command. With grep you can rifle through just one file, all of a directory, the process table, and much more without batting an eyelid.
The stalwart that is grep comes to a command prompt near you in a few forms, but I'll come to that a little later. First, I want to get my hands dirty
...Buy this article as PDF
(incl. VAT)