find or replace through sed
Dear all,
I am successfully execute the below command in my script :
sed '/findstring/s//replacestring/g' find1.txt > /root/Desktop/output1.txt
but when I want to replace it with some runtime input it fails .
I want to accept a string from user and then find, replace it.
Below is my script :
#/bin/bash
#Script for Find and Replace
#filename=$1
findstring=$1
replacestring=$2
echo $findstring
echo $replacestring
#sed '/$findstring/s//$replacestring/g' find1.txt > /root/Desktop/output1.txt
# Below line executed successfully.
#sed '/tea/s//milk/g' find1.txt > /root/Desktop/output1.txt
#sed -i 's/findstring/replacestring/g' *
echo "Script executed successfully"
Pls help how could I achieve this.
Thanks & Regards
Adarsh Sharma
|