This post is about simple bash shell scripts that finds all files that use particular method.
In my previous post: Product moving parts as source for test strategy, I described how I use github pull request in order to discover which part of application changed in order to create regression test strategy.
Code that changed could be some helper method or .css and .jpg assets that are used in various places in code base. And those places are not part of pull request. So I need an automated way to find all places where is that helper method used.
For that purpose I use simple bash script. You need to know loop programming concept and a unix utility commands cat and grep.
Here is bash script:
#!/bin/bash for i in `cat pull_request_items.txt` do echo $i grep -H -r "$i" * | grep -v cache | grep -v manifest done
And content of pull_request_items.txt
our_overview_gettingstarted.png tour_overview_lessonhighlights.png tour_overview_originals.png
Script reads items from txt file, and each row value is searched in project codebase using grep utility. Search is recursive in all subfolders.
Output contains files that contain searched items.
Manual part was to copy/paste from pull request to pull_request_items.txt file and do some editing in order to clean not important pull request information.
Why not use some fancy editor like sublime? Because presented utilities are installed on almost every linux machine in the world and i can use this script out of the box.by