Skip to content

Instantly share code, notes, and snippets.

@vishaltelangre
Last active December 17, 2015 10:59
Show Gist options
  • Select an option

  • Save vishaltelangre/5598567 to your computer and use it in GitHub Desktop.

Select an option

Save vishaltelangre/5598567 to your computer and use it in GitHub Desktop.
Find files for desired text (shell)
# 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