Select grep from mulitple options

Disclaimer: this post is mostly related to the job of verification engineers, but the message I am conveying is universal.

Admit it, you always wanted to have your own database of useful grep commands. And what is the best way to do it? Write a hard-coded, cryptic script in BASH! I know, I know, why not doing it in Python? While I do love it, I am still very fond of good ol’ bash scripting.

 

As a verification engineer, I often find myself using and making different grep commands – search this type of error, that type of packet, locate that missing ACK, and the such. It occurred to me how it would be awesome to have all these greps in one spot and simply invoke the one I want on demand. You guess what comes next – let’s write a script for it!

 

In my mind, I wanted it to be a gui-like solution, so that I can select visually what I want to execute. For this purpose in bash I usually use very neat program called zenity, which allows creation of the very basic guis. Rest of this idea was pretty straightforward, simply hardcode desired commands and voala there you have it:

I can then simply perform the search I need. For example, if you want to get all those nasty messages related to virtual interfaces, simply select NOVIF and the result comes in handy:

Now that I think of it, this is how you can build your own small database of commands that you execute often: grep, lmstat, ps, etc.

Main take from this small venture however is the following. While idea is pretty basic, I always liked to play with things like this, because without exception I end up learning something new along the way, which I neither planned nor expected. In this case, I learned more about “ps” command in linux, how neat is that?

And that is the whole point of it actually – play with different ideas that come to your mind, as they will almost always lead to you learning and exploring something else, which will in the long run, make you a more knowledgeable person.

If you are interested in how I implemented this script, drop me an email to [email protected] or comment below, and I will be glad to show it to you.

You may also like

Leadership
Milos

Here’s How To Beat Fear of Interviews

John is a verification engineer with seven years of experience. He has successfully completed multiple projects in his career and has also led a team of five people. However, despite having a clear track record of being good at his

Read More »
Join my Mailing list!