helm/bin/replace.sh
Henrik Lissner bf2c16dac3 Append .sh to bin scripts
This help distinguish personal scripts from binaries in $PATH
2016-10-19 21:38:58 +02:00

15 lines
320 B
Bash
Executable file

#!/bin/sh
#
# 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" "$@")
temp="${TMPDIR:-/tmp}/replace_tmp.$$"
for item in $items; do
sed "s/$find_this/$replace_with/g" "$item" > "$temp" && mv "$temp" "$item"
done