I have a bash script which has about 2000 lines of code and in this script on various lines the scripts writes some status messages to a log file i.e. LogFiles.txt,bills.txt I want to comment(search and replace the text) for all the lines writing the status messages in LogFiles.txt only
Sample script file:
echo "+++++++++++++++++++++">>bills.txt
echo "doing some stuff">>bills.txt
echo "starting
to execute some commands">>LogFiles.txt
echo "----------------------">>LogFiles.txt
ls
cat someFile.txt| grep "search me"
echo "search results found">>LogFiles.txt
echo "----------------------">>LogFiles.txt
echo "+++++++++++++++++++++">>bills.txt
echo "doing some more stuff">>bills.txt
some other commands...
echo "finshing
script
execution">>LogFiles.txt
echo "----------------------">>LogFiles.txt
desired Output:
echo "+++++++++++++++++++++">>bills.txt
echo "doing some stuff">>bills.txt
/*echo "starting
to execute some commands">>LogFiles.txt*/
/*echo "----------------------">>LogFiles.txt*/
ls
cat someFile.txt| grep "search me"
/*echo "search results found">>LogFiles.txt*/
/*echo "----------------------">>LogFiles.txt*/
echo "+++++++++++++++++++++">>bills.txt
echo "doing some more stuff">>bills.txt
some other commands...
/*echo "finshing
script
execution">>LogFiles.txt*/
/*echo "----------------------">>LogFiles.txt*/
uptill now i have used the following command but the results are not good:
sed -e 's/echo/\/\*echo/gI' -e 's/LogFiles.txt/LogFiles.txt\*\//gI' samplescript.sh
the results that this command produces:
/*echo "doing some stuff">>bills.txt
/*echo "starting
to execute some commands">>LogFiles.txt*/
/*echo "----------------------">>LogFiles.txt*/
ls
cat someFile.txt| grep "search me"
/*echo "search results found">>LogFiles.txt*/
/*echo "----------------------">>LogFiles.txt*/
some other commands...
/*echo "finshing
script
execution">>LogFiles.txt*/
/*echo "----------------------">>LogFiles.txt*/
here the problem arises when the first part of the sed -e command replaces all the echo with /*echo which is a wrong approach since i do not need to comment echos for bills.txt.