Add sys/subst.sh shellscript helper
This commit is contained in:
parent
6b00784cb1
commit
6437e0049b
1 changed files with 20 additions and 0 deletions
20
sys/subst.sh
Executable file
20
sys/subst.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
a="$1"
|
||||
b="$2"
|
||||
if [ -z "$a" ]; then
|
||||
echo "Usage: sys/subst.sh [old] [new]"
|
||||
exit 1
|
||||
fi
|
||||
#[ -z "$a" ] && a="r_str_chop "
|
||||
#[ -z "$b" ] && b="r_str_trim "
|
||||
git grep "$a" libr binr | less -R
|
||||
if [ -n "$b" ]; then
|
||||
FILES=`git grep "$a" libr binr | cut -d : -f 1 | uniq `
|
||||
for f in $FILES ; do
|
||||
echo "Sedded $a"
|
||||
sed -e "s/$a/$b/g" < $f > $f.sub
|
||||
mv $f.sub $f
|
||||
done
|
||||
else
|
||||
echo "Oops"
|
||||
fi
|
||||
Loading…
Reference in a new issue