Skip to content

Instantly share code, notes, and snippets.

@danhart
Last active December 20, 2015 20:59
Show Gist options
  • Save danhart/6193895 to your computer and use it in GitHub Desktop.
Save danhart/6193895 to your computer and use it in GitHub Desktop.
Find lines matching filenames in a directory
# First argument is the directory containing the filenames you wish to match against for
# Second argument is the directory you wish to search within
# e.g. matching_filenames public/images public/less
# will match against all filenames (recursively) in public/images by searching the public/less directory
# Tested on OS X
# Dependency: Ack
function matching_filenames() {
find ${1} -type f -exec basename {} \; | xargs -L1 -J % ack % ${2}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment