Skip to content

Instantly share code, notes, and snippets.

@maxlawton
Created August 18, 2015 16:22
Show Gist options
  • Save maxlawton/811d646a5cf73cd7a2f3 to your computer and use it in GitHub Desktop.
Save maxlawton/811d646a5cf73cd7a2f3 to your computer and use it in GitHub Desktop.
Bash find/sed script
#!/usr/bin/env bash
FIND=$(echo "$1" | sed -e 's/[\/&]/\\&/g')
shift
REPL=$(echo "$1" | sed -e 's/[\/&]/\\&/g')
shift
# EXPR="s/"${FIND}"/"${REPL}"/g"
OPTIONS="$@"
find . -type f $OPTIONS -print0 | xargs -0 sed -i "s/$FIND/$REPL/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment