2017-04-21 22:59:04 -07:00
|
|
|
#!/usr/bin/env bash
|
2016-03-03 07:46:27 -08:00
|
|
|
#
|
|
|
|
# Find and replace by a given list of files.
|
|
|
|
#
|
|
|
|
# replace foo bar **/*.rb
|
|
|
|
|
|
|
|
find_this="$1"; shift
|
|
|
|
replace_with="$1"; shift
|
|
|
|
|
2016-11-21 20:58:53 -08:00
|
|
|
items=( $(ag -l --nocolor "$find_this" "$@") )
|
|
|
|
for item in ${items[@]}; do
|
2017-04-21 22:59:04 -07:00
|
|
|
sed -i "s/${find_this}/${replace_with}/g" "$item"
|
2016-03-03 07:46:27 -08:00
|
|
|
done
|