#! /bin/bash
#

mysearch=$1
myrep=$2
myfile=$3

if [ $# -eq 3 ]
then
    read -p "***  Are you sure you want to replace \"$mysearch\" with \"$myrep\" in \"$myfile\"?  *** " -n 1 -r

    if [[ $REPLY =~ ^[Yy]$ ]]
        then
            echo ""

            # Find and replace
            sed -i 's/'$mysearch'/'$myrep'/g' $myfile

	    echo "***  Done!  ***"
	    echo "***  cat $myfile  ***"
            cat $myfile
        else
            echo ""
	    echo "***  Operation Cancelled   ***"
    fi
else
    echo "***  Missing Parameters! (esed search replace file)  ***"
fi

exit
