Find and replace
It can be convenient to find and replace by a given list of files from the command line:
replace foo bar **/*.rb
My replace
script looks like this:
#!/bin/bash
find_this="$1"
shift
replace_with="$1"
shift
items=$(ag -l --nocolor "$find_this" "$@")
IFS=$'\n'
for item in $items; do
sed "s/$find_this/$replace_with/g" "$item" > tmpfile && mv tmpfile "$item"
done