blob: 5305b75eab9ebf9060ddfda52d5b14f51a7ad62e [file] [log] [blame]
Christopher Piro094823a2007-07-18 00:26:12 +00001#!/bin/sh
2
3
4if [ $# -lt 2 ]; then
5 echo "usage: substitute.sh <variable to replace> <value to replace with> <filename | STDIN>"
6 exit 1
7fi
8
9if [ $# -eq 3 ]; then
10 VARIABLE=$1
11 VALUE=$2
12 FILENAME=$3
13
14 echo "replacing $VARIABLE with $VALUE in $FILENAME"
15 sed -e "s/$VARIABLE/$VALUE/" $FILENAME > "$FILENAME"_tmp
16 mv "$FILENAME"_tmp $FILENAME
17 exit 0
18fi
19
20if [ $# -eq 2 ]; then
21 while read line;
22 do
23 VARIABLE=$1
24 VALUE=$2
25 FILENAME=${line}
26
27 echo "replacing $VARIABLE with $VALUE in $FILENAME"
28 sed -e "s/$VARIABLE/$VALUE/" $FILENAME > "$FILENAME"_tmp
29 mv "$FILENAME"_tmp $FILENAME
30 done
31 exit 0
32fi
33