I have a text file and I want to prepend some text to the first line.I tried something like this:sed -i '1i\'string fileHowever this inserts a new line to the text file. 
How to add text to the start of a line?
text processing
This should work with GNU sed: sed -i '1s/^/string/' fileit's different from your solution in not adding the new line.testBefore running command, the content of file is this:sometextherealreadyAfter running the command:stringsometextherealready