How to use AWK/SED to insert a line?
Posted on 2008-10-01
I have a file that looks like this:
I want to find Fake=Fake and insert another line before it. This change then needs to be written back to the same file. The replacement value is in a variable, say, $__changes
I have been trying sed but for some reason it creates a 0byte file if the source and target files are the same. I am ok if you can provide an awk solution.
cat 'file1.txt' | sed '
' > 'file1.txt'
This doesn't work if I try a variable in the replacement text.
Please note I need to insert before only the first instance of the match.
Thanks for your help.