bin/replace: refactor
This commit is contained in:
parent
a760a43502
commit
19bd70185d
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Find and replace by a given list of files.
|
||||
#
|
||||
|
@ -8,7 +8,6 @@ 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"
|
||||
sed -i "s/${find_this}/${replace_with}/g" "$item"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue