So far I've been able to find how to add a line at the beginning of a file but that's not exactly what I want. I'll show it on a example
File content
some text at the beginning
Result
<added text> some text at the beginning
It's similar but I don't want to create any new line with it...
I would like to do this with sed
if possible.
If the file is only one line, you can use:
If it's more than one line. one of:
I've included the latter so that you know how to do ranges of lines. Both of these "replace" the start line marker on their affected lines with the text you want to insert. You can also (assuming your
sed
is modern enough) use:to do in-place editing.