# the search-string, so this is loosely based on:
#GIT GREP FILE EXTENSION CODE#
# The rest of the code in this loop is here to move the last argument in While doĮrr=$(git grep - `git ls-files $moved | grep -iv "$EXCLUDES"` \ # arg-list to the list of files to search.Įrr="fatal: bad flag '-' used after filename" # If git-grep returns this "fatal." then move the last element of the # Store the stuff that is moved from the arguments. # Rebuild the list of fileendings to a good regexpĮXCLUDES=`echo $EXCLUDES | sed -e 's/ /\\|/g' -e 's/.*/\\.\\(\\)/'` # therefor I crafted the while-thing that moves path-parts to the other side If you want the search to start somewhere other than the current working directory, specify the path. at the start denotes the current directory.find searches recursively in all the directories below the given path. type f -name '.txt' This will list all files with the extension. When it opens, run the command below: find. We can search string in multiple files by providing file name or extension with the help asterisk. Just press Ctrl+Alt+T on your keyboard to open Terminal. In previous example we have searched given string in a single file but real world problems are more than that. # But there is issues with giving extra path information to the script \poet.txt Search String In A File Search String In Multiple Files. # The basic setup of this script is from here: # NOTE: The filetypes to exclude is hardcoded for my specific needs. # Wrapper of git-grep that excludes certain filetypes. By default, grep displays the matched lines, and it can be used to search for lines of text that match one or more regular expressions, and it outputs only the matched lines.