sed insert new line does not update file

Hi all,

I have a file called "text.cpp" with the first line of "1"
afterwards I tried in Ubuntu to type the following

sed '12iasdasdasdasdsad' test.cpp > output.txt

however when I tried to see the result of output.txt

#cat output.txt 
1

why is the line 12 is not updated to the new output.txt? :confused:

thank you

sed '12i\
asdasdasdasdsad' test.cpp > output.txt

you must add a new line after your backslash .

---------- Post updated at 05:31 AM ---------- Previous update was at 05:30 AM ----------

still does not update the output.txt .. it consist only "1" even after I removed the old output.txt

What that sed is doing? and what you want to achieve from this?:confused:

I have a test.cpp with a "1" on the first line. I want to copy this respective file to other file with additional lines in line 12..

your file has at least 12 lines ?

Ok, I found a similar way

sed '1i\
> your text goes here' test.cpp > testfile.txt

thank you everyone!:b: