Skip to content

Instantly share code, notes, and snippets.

@flashingpumpkin
Created September 7, 2011 14:08
Show Gist options
  • Select an option

  • Save flashingpumpkin/1200647 to your computer and use it in GitHub Desktop.

Select an option

Save flashingpumpkin/1200647 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Usage: bulkreplace <path> <filetype> <find_pattern> <replace>
function infile(){
find $1 -name "*$2" -exec grep -H "$3" {} \; | sed 's/:.*//';
}
for f in $(infile $1 $2 $3); do replace "$3" "$4" -- $f; done
$ ./bulkreplace ./src py "TODO:" "REMEMBER:"
./src/foo.py converted
./src/bar.py converted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment