I\'m trying to write a simple Bash script. I have a simple \"template\" variable:
template = \"my*appserver\"
I then have a function (
Here's a bash script that wraps this up
$ search_and_replace.sh "test me out" "test me" ez
ez out
#!/bin/bash
function show_help()
{
echo ""
echo "usage: SUBJECT SEARCH_FOR REPLACE_WITH"
echo ""
echo "e.g. "
echo ""
echo "test t a => aesa"
echo "'test me out' 'test me' ez => ez out"
echo ""
exit
}
if [ "$1" == "help" ]
then
show_help
exit
fi
if [ -z "$3" ]
then
show_help
exit
fi
SUBJECT=$1
SEARCH_FOR=$2
REPLACE_WITH=$3
echo "$SUBJECT" | sed -e "s/$SEARCH_FOR/$REPLACE_WITH/g"