I am working on a project that has view formats. Frequently when grepping the project, I want to grep only one format. I added a couple bash aliases to help me pipe a list of files to grep. Grepping through a specific list of files can be useful in many situations. Here is how to grep a list of files or set up quick aliases to make it easy to do. First you need to get a list of files, in my case I do this with find and looking for the touch format alias find_touch_views='find app/views/ -name "*.touch.erb"' This generates the list of files you want to grep, now you just pipe that list to grep using xargs to grep each file for a specific word. alias grep_touch_views='find_touch_views | xargs grep -Ri "$0"' in the end this lets me run grep_touch_views touch-nav Modify these to fit your needs and add them to your ~/.bash_profile alias find_touch_views='find app/views/ -name "*.touch.erb"'alias grep_touch_views='find_touch_views | xargs grep -Ri "$0"' which gives me a list of all the views that contain touch-nav.

blog comments powered by Disqus
Dan Mayer Profile Pic
Welcome to Dan Mayer's development blog. I primary write about Ruby development, distributed teams, and dev/PM process. The archives go back to my first CS classes during college when I was first learning programming. I contribute to a few OSS projects and often work on my own projects, You can find my code on github.

Twitter @danmayer

Github @danmayer