I'm having some trouble with sed and seeing a variable providing a number instruction for an insertion of text at a specific line.
here is the working code without the variable:
sed -i '1i\NewLineHere\' ~/file/location/here.txt
I need to change the number 1 to $var, but with the letter 'i' remaining next to it (no space), while not being seen as part of the variable. I use " " instead of ' ' so that sed can see the variables correctly, I have tried countless different attempts and none have worked. An example of what the problem looks like without any attempt to disconnect the 'i' from the variable while keeping it next to it:
sed -i "$vari\NewLineHere\" ~/file/location/here.txt
Thanks in advance for any suggestions or answers