i have few lines in a file... i am reading them in a while loop so a particular line is held is $line1.. consider a modified line is held in $line2.... i want to replace $line1 with $line2 in the same file... how to do it..?
i have come up till the below code
sed "s/$line1/$line2/g" tmpfile.sql
the code replaces fine but its not replaced in same file..it just displays it, i could direct to another temporary file but i wast the replacement to be in same file... plz help..
while read line1
do
if [[ `expr match "$line1" ".*DEFAULT NULL.*"` != "0" ]]; then
line2="blah blah blah"
sed -i 's/$line1/$line2/g' tmpfile.sql
fi
done < tmpfile.sql
i am not getting any error but when i open tmpfile.sql its not changed....