Skip to content

Instantly share code, notes, and snippets.

@RatoX
Created March 1, 2018 13:25
Show Gist options
  • Save RatoX/6071473e80edc9e0569c19333ecedd25 to your computer and use it in GitHub Desktop.
Save RatoX/6071473e80edc9e0569c19333ecedd25 to your computer and use it in GitHub Desktop.
Bulk replace with ag for MAC
#!/bin/bash
# Bulk replace for MAC
# ag <https://github.com/ggreer/the_silver_searcher>
# original idea: https://gist.github.com/hlissner/db74d23fc00bed81ff62
# usage: replace [search] [replace]
function replace {
ag -0 -l "$1" | xargs -0 sed -i "" -E "s/$1/$2/g"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment