A little help with Grep

January 14, 2011 | 1 Comment

I was triggered by this post on ReadWriteWeb to write a small bash script to make it easy for me to use grep to look for a pattern in my source code.

The post on ReadWriteWeb points to the -i -r -E -n -C –colors options to make grep recursively and case insensitively search for a pattern and displays the result with colors. I wanted to make it easy for me to use all these by doing search . “->foo\(“ for example.

First, I created the following search.sh script and made it executable

1
2
#!/bin/bash
grep -inIEr --color=ALWAYS $2 -C1 $1

Then, I edited my .bash_profile file and added

1
alias search='/path_to/search.sh'

Then, I reloaded my profile by doing source .bash_profile and tested my search function

1
search . "->load\->"

Nothing complicated but it’s pretty handy

Filed under: Computing, Système

Tagged with: , , ,

Liked this page?

Tweet it

Subscribe to the RSS feed or sign up for the newsletter now.

Posts related to A little help with Grep

1 Comment to "A little help with Grep"

  1. Trackback on Samantha Halfon on January 14, 2011 at 10:31 pm

    New blog post: A little help with Grep: I was triggered by this post on ReadWriteWeb to write a small bash scrip… http://bit.ly/g6t43r

Name (required)

Email (required)

Website

Leave a Reply

  • About Me


    photo of Samantha Halfon Samantha Halfon
    Software Engineer
    blueKiwi software
    Paris, France
    I enjoy playing with my computer(s), listening to Bob Dylan (and related artists) and watching movies (especially if they were directed by Martin Scorsese or John Cassavetes). Sometimes, I play a little guitar... If not doing any of the above, I am either riding a small red bike around Paris, or, making videos. About my videomaking please check out World Wide Angle and its blog.