I\'m trying to insert text to the third line in a file using sed, and the syntax I\'ve found on other forums is:
sed -i \'\' \"3i\\ text to insert\" file
I've found that I have to insert a \ at the end of the line to be inserted, otherwise it concatenates it at the beginning of the original line. So, if I want to insert a new third line,...
sed -i '' '3i\ New line to be inserted.\ ' file