Last active
December 17, 2015 10:59
-
-
Save vishaltelangre/5598567 to your computer and use it in GitHub Desktop.
Find files for desired text (shell)
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
| # UPDATE (lot much easier) | |
| grep -Rn 'blah' some/dir | |
| # ======================= | |
| # Find files which contains the "everybody wants me" text | |
| # | |
| # grep -H "everybody wants me" some/dir -R | cut -d: -f1 | |
| # | |
| # it will print matching file names | |
| # | |
| # so what if we create handy command for it as: | |
| # | |
| grep -H $0 $1 -R cut -d: -f1 | |
| # here, $0 -> text to search for | |
| # $1 -> directory path to search within | |
| # USAGE: | |
| # find-files-for "everybody wants me" ~/delicious | |
| # TODO: | |
| # provide options such as: | |
| # -q for search query, -d for directory, -r (optional) for recursive search |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment