Created
November 4, 2014 18:30
-
-
Save nlitsme/ccd9a7ef05b9b3e1715f to your computer and use it in GitHub Desktop.
combine find, xargs and grep in one command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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[@]}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, now i discovered that
grep
has a-r
option, to recursively search a directory.