-
-
Save Gen2ly/2858162 to your computer and use it in GitHub Desktop.
Search file(s) for keyword
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 | |
# Search file(s) for keyword | |
# Display usage if no parameters given | |
if [[ -z "$@" ]]; then | |
echo -e " ${0##*/} <string> <file/path> - search recursively for keyword in files" | |
exit | |
fi | |
if [ -z "$2" ]; then | |
loc=$(pwd) | |
else | |
loc="$2" | |
fi | |
echo " Searching..." | |
grep -ilr "$@" "$loc" 2>&1 | grep -v "No such" | grep -v "Permission denied" | sed "s:^\.::g" | sed "s:$(pwd)::g" | sort | uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment