I understand this question has been asked a lot in the bash / perl world.
I can appreciate the answer here Interactive search and replace from shell
:argdo %s#SEARCH#REPLACE#gec |update
This works okay for me, and I do like and use vi.
But I want to take this concept to the next level
the answer given at the above link is as follows:
sed -i -e 's/foo/bar/g' filename
again this works.
so in the interest of making this an executable / interactive script.. I tried something like this:
#!/bin/sh
read -r -p "Search For: " FIND
read -r -p "Replace With: " REPLACE
read -r -p "Full Path To File: " FILE
sed -i -e 's/"${FIND}"/"${REPLACE}"/g' "$FILE"
however, if you are reading this, you probably know that you can't run sed
like this inside a bash script.
Any thoughts on making this find_replace.sh
a working script?
Thanks for reading.