Skip to content

Instantly share code, notes, and snippets.

@elundmark
Created January 13, 2012 00:41
Show Gist options
  • Save elundmark/1604036 to your computer and use it in GitHub Desktop.
Save elundmark/1604036 to your computer and use it in GitHub Desktop.
Search text files in current folder (Recursive, RegExp)
#!/bin/bash
KEYWORD=$(zenity --entry --title="Search folder for..." --text="RegExp:" --entry-text "");
case "$?" in
1 )
exit 1
;;
esac
if [[ "${KEYWORD}" = "" ]]; then
exit 1
fi
rm -f "${PWD}/grep_text_search.txt"
cd "${PWD}"
echo "Searched for '${KEYWORD}' inside '${PWD}'" >> "${PWD}/grep_text_search.txt"
echo " " >> "${PWD}/grep_text_search.txt"
RESULTSTRING=$(grep -inIEr --exclude-dir=".git" --exclude-dir=".svn" --exclude="grep_text_search.txt" --regexp="${KEYWORD}" "${PWD}")
echo "${RESULTSTRING}" >> "${PWD}/grep_text_search.txt" &&\
gedit "${PWD}/grep_text_search.txt" &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment