insert new line in files

Steve Bertrand steve at ibctech.ca
Fri Feb 6 15:17:49 PST 2009


Adam Vande More wrote:
> Dan Nelson wrote:

>> You want:
>>
>> sed -e '5i\
>> test' test.txt
>>
>> i.e. a linebreak after the backslash.
>>
>>   
> I had actually tried that too:
> 
>> sed -e '5i\
> ? test' text.txt
> sed: 1: "5i
> test
> ": command i expects \ followed by text

Try:

# sed -e "5i\\
? test" text.txt

Note the double-quotes and two \\.

I just ran into this today ;)

Steve


More information about the freebsd-questions mailing list