Last active
August 29, 2015 14:04
-
-
Save okomestudio/cc3cd23b3824aace571a to your computer and use it in GitHub Desktop.
Search for files containing a specified string.
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
#!/bin/bash | |
############################################################################## | |
# findstr | |
# | |
# Search for files containing a specified string. Show the file path, | |
# line number, and the line itself containing a specified string. | |
# | |
# EXAMPLE: | |
# | |
# To search for all the files with the file extension .html containing | |
# a string "body" under the current directory and all its | |
# subdirectories, do: | |
# | |
# $ findstr . "*.html" "body" | |
# | |
find $1 -name \*$2 -exec grep -nH "$3" {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment