Skip to content

Instantly share code, notes, and snippets.

@nlitsme
Created November 4, 2014 18:30
Show Gist options
  • Save nlitsme/ccd9a7ef05b9b3e1715f to your computer and use it in GitHub Desktop.
Save nlitsme/ccd9a7ef05b9b3e1715f to your computer and use it in GitHub Desktop.
combine find, xargs and grep in one command
#!/bin/bash
GREPARGS=()
FINDPATHS=()
while [[ $# != 0 ]]; do
if [[ -d "$1" ]]; then
FINDPATHS+=("$1")
else
GREPARGS+=("$1")
fi
shift
done
find "${FINDPATHS[@]}" -type f | x0 grep "${GREPARGS[@]}"
@nlitsme
Copy link
Author

nlitsme commented May 20, 2016

So, now i discovered that grep has a -r option, to recursively search a directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment