Created
October 14, 2013 18:35
-
-
Save ejhayes/6980009 to your computer and use it in GitHub Desktop.
Grep, sed usage examples.
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 | |
# Recursively find all files that match a specific pattern | |
# and contain a specific string inside of it | |
grep -rl "SEARCH_FOR_WHAT" --include="*.htm" --include="*.html" /path/to/whatever | |
# And perform text replacement (in-line mode) | |
find . | xargs sed -i 's/BEFORE/AFTER/g' | |
# Using find instead of grep | |
find . -type f -name "*.htm" -o -name "*.html" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment