harmonizing shebang for scripts
[feisty_meow.git] / scripts / core / search_replace.sh
1 #!/usr/bin/env bash
2
3 # a break out of the popular replace_pattern_in_file function that
4 # can work with multiple files.
5
6 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
7
8 pattern="$1"; shift
9 replacement="$1"; shift
10
11 if [ -z "$1" -o -z "$pattern" -o -z "$replacement" ]; then
12   echo This script requires a simple pattern to search for in a set of files,
13   echo the replacement for the pattern, and a list of files.
14   exit 1
15 fi
16
17 # loop across the file names we were given.
18
19 while true; do
20   patt1="$1"; shift
21   if [ -z "$patt1" ]; then 
22     break;
23   fi
24
25   for currfile in $patt1; do
26     replace_pattern_in_file "$currfile" "$pattern" "$replacement"
27   done
28
29 done
30