File: subst.sh

package info (click to toggle)
iaito 6.0.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,792 kB
  • sloc: cpp: 45,196; sh: 673; xml: 315; python: 234; makefile: 125; ansic: 9
file content (21 lines) | stat: -rwxr-xr-x 400 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/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 "
WHERE="src"
git grep "$a" ${WHERE} | less -R
if [ -n "$b" ]; then
	FILES=`git grep "$a" ${WHERE} | 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