Hi,
I am creating a script to do a find and replace single/multiple lines in a file with any number of lines.
I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE
print $FIND gives
Hi How r $u
Rahul()
Note: $FIND can contain one or multiple lines along with special characters
print $REPLACE gives
#Hi How r $u
#Rahul()
i am $fine
thanks()
Note: $REPLACE can contain one or multiple lines along with special characters
Now, I want to replace $FIND with $REPLACE in "introduction.sh". Can anyone help me in achieving this? i have gone through lot of threads and forums but no success.
I have tried below command but it did not work
sed "s/'$FIND'/'$REPLACE'/g" introduction.sh > introduction.sh.a
mv introduction.sh.a introduction.sh
Also tried below command
perl -pi -e "s:$FIND:$REPLACE:g" introduction.sh
Also, tried awk
awk '{gsub(a,b);print}' a="$FIND" b="$REPLACE" introduction.sh > introduction.sh.a
mv introduction.sh.a introduction.sh
But this gave an error as below
awk: syntax error near line 1
awk: illegal statement near line 1