Skip to content

Instantly share code, notes, and snippets.

@ejhayes
Created October 14, 2013 18:35
Show Gist options
  • Save ejhayes/6980009 to your computer and use it in GitHub Desktop.
Save ejhayes/6980009 to your computer and use it in GitHub Desktop.
Grep, sed usage examples.
#!/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