Created
April 11, 2018 05:58
-
-
Save santicalvo/3719a87a67de10a2ae258d506fb4196f to your computer and use it in GitHub Desktop.
Find number of ocurrences of string recursively in bash
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
| #!/usr/bin/env bash | |
| # We require two arguments: folder to search and word | |
| ocurrences=$(find $1 -type f -exec grep -io $2 {} \; | wc -l) | |
| if [ "$ocurrences" -gt 0 ];then | |
| echo "more than 0: $ocurrences" | |
| else | |
| echo "No ocurrences: $ocurrences" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment