find or replace through sed

view full story

http://www.linuxquestions.org – 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/Deskto (HowTos)