Created
February 2, 2015 19:52
-
-
Save gallir/4b88005310587b056ca4 to your computer and use it in GitHub Desktop.
Seach a word recursively in all files under the current working direcrtory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
if [ $# -eq 0 ] | |
then | |
echo "No word supplied" | |
fi | |
word=$1 | |
find . -type f -and -not -path '*/.git/*' -and -not -path '*/.svn/*' -exec grep -i -H "$word" {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy the file to a directory in your path, for example: references
chmod +x references
Usage:
references word_to_search
Example:
gallir@darwin:/tmp/linux-3.18.5$ references spin_unlock
./block/bio.c: spin_unlock(&bs->rescue_lock);
./block/bio.c: spin_unlock(&bs->rescue_lock);
./block/bio.c: spin_unlock_irqrestore(&bio_dirty_lock, flags);
./block/bio.c: spin_unlock_irqrestore(&bio_dirty_lock, flags);
./block/blk-cgroup.c: spin_unlock(&blkcg->lock);
....
PS: You can do it with grep -R... but I'm an old fan of find ;)