Skip to content

Instantly share code, notes, and snippets.

@jaburns
Created May 9, 2018 18:05
Show Gist options
  • Save jaburns/c850773ca52d081092f3c48a4fce6c00 to your computer and use it in GitHub Desktop.
Save jaburns/c850773ca52d081092f3c48a4fce6c00 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
find_files() {
ag "$1" | cut -d: -f1 | sort | uniq
}
do_replace() {
echo "Finding files matching orignial string $1"
for f in $(find_files "$1"); do
echo " -> Replacing string in file $f"
sed -i "s/$1/$2/g" "$f"
done
}
do_replace OLD_0 NEW_0
do_replace OLD_1 NEW_1
# etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment