annotate src/chg @ 0:6ee11bf9e3ea

Initial revision
author jcid
date Sun, 07 Oct 2007 00:36:34 +0200
parents
children
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 #!/bin/sh
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 #
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 # Shell script for name changing source code
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4 #
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 if [ ! $# = 3 ]; then
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 echo "Usage: chg <source> <old_word> <new_word>"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 echo " (this script changes <source> directly)"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 exit 1
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 fi
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 if [ ! -r $1 ]; then
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13 echo "source file ->$1<- doesn't exist..."
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14 exit 1
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15 fi
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 if [ ! -r $1.BAK ]; then
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18 echo "creating backup file: $1.BAK"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 cp $1 $1.BAK
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20 fi
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22 sed "s/$2/$3/g" $1 > out
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23 #sed s/$2/$3/ $1 > out
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24 rm $1
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 mv out $1
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 echo "done!"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28