Hi Everybody,
Can we replace the contents of a file without using a temporary file.
For ex:
I need to relpace the value "old" with "new", I can do it using the sed replace pattern, but I do not want to use a temporary file.
Also, from the questions posted in the past I could see a fantastic command to do this
printf '1,$ s/old/new/g\nw! samp.txt\nq!'| ex - samp.txt
But, with the same command I am not able to replace the value of a variable
For ex: var1='new'
printf '1,$ s/new/$var1/g\nw! samp.txt\nq!'| ex - samp.txt
The above command doesn't replace the value of the variable.