I am using environment variables and want to simply find a line containing environment variable and replace it with the entire line that consists of special characters.
Details:
file="dir1/file1"
In short, I am trying to find a line in a file that contains $file
and as soon as it finds it, replace entire line with the below line:
('test/$file', [your.name, your.age, your.address]),
(please note the comma in end)
Command that I tried:
sed -i '/'$file'.*/c ('"'test/$file'"'," [hello.name, hello.age, hello.address]),' file_name
sed: 1: "file": invalid command code f
Please note that I want to replace the entire line. The problem lies with the complex string that I am replacing which consists of brackets, commas, slashes. It is not getting replaced.