helm/bin/replace
2017-04-22 01:59:04 -04:00

14 lines
276 B
Bash
Executable file

#!/usr/bin/env bash
#
# Find and replace by a given list of files.
#
# replace foo bar **/*.rb
find_this="$1"; shift
replace_with="$1"; shift
items=( $(ag -l --nocolor "$find_this" "$@") )
for item in ${items[@]}; do
sed -i "s/${find_this}/${replace_with}/g" "$item"
done