Created
November 20, 2015 16:41
-
-
Save stevekm/a8880faf74a949bc3a61 to your computer and use it in GitHub Desktop.
Examples of how to use -exec and xargs in combination with find and grep to find and search files
This file contains 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 | |
# find all the shell scripts I have written that use the [ ] test function | |
# the [ needs to be escaped! | |
# using xargs | |
find ~/projects/ -type f -name "*.sh" -print0 | xargs -0 grep -l '\[' | |
# using exec | |
find ~/projects/ -type f -name "*.sh" -exec grep -l '\[' {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment