regex working on Vim but not in sed



Hello,

I have this substitution regex working properly when executed from
inside Vim.

%s/\(instance_hostname.*\n.*\n.*\n.*\)myhostname.net/\1newhostname.net/
g

Since it has to be executed on hundreds of files I've tried to convert
it into a sed one liner but with no success.

I've tried this combinations (changed quoting, [un]escaping
characters):

sed -i 's/\(instance_hostname.*\n.*\n.*\n.*\)myhostname.net/
\1newhostname.net/g' myfile.txt
sed -i "s/\(instance_hostname.*\n.*\n.*\n.*\)myhostname.net/
\1newhostname.net/g" myfile.txt
sed -i 's/(instance_hostname.*\n.*\n.*\n.*)myhostname.net/\
\1newhostname.net/g' myfile.txt

I'm obviously missing something, but don't know what.
Can somebody help me please?

Thanks in advance.
.



Relevant Pages

  • Re: [slrn]/[vim] Follow-up posts and wordwrap
    ... nearly every single newsreader implemented it incorrectly. ... So keep you damn lines at less than 79 characters in length even when you're ... With regard to vim, Real Men insert their own internal line boundaries ... The nice thing about fmt is that it strips the trailing space on internal ...
    (news.software.readers)
  • Re: [slrn]/[vim] Follow-up posts and wordwrap
    ... nearly every single newsreader implemented it incorrectly. ... So keep you damn lines at less than 79 characters in length even when you're ... With regard to vim, Real Men insert their own internal line boundaries ... The nice thing about fmt is that it strips the trailing space on internal ...
    (news.software.readers)
  • Re: [slrn]/[vim] Follow-up posts and wordwrap
    ... nearly every single newsreader implemented it incorrectly. ... So keep you damn lines at less than 79 characters in length even when you're ... With regard to vim, Real Men insert their own internal line boundaries ... The nice thing about fmt is that it strips the trailing space on internal ...
    (news.software.readers)
  • Re: OT: Unicode and vi(m). Was Re: Great SWT Program
    ... Running console-mode vim in GNOME's terminal emulator ... After spending a few minutes reading online help about digraphs, ... I was able to enter the characters he mentions as being enterable ... but it probably won't add appropriate headers. ...
    (comp.lang.java.programmer)
  • Re: Alt Gr key troubles in FreeBSD
    ... applications and also because i mostly write those characters in vim. ... I used to use nedit, before vim, and i am sure i had ...
    (freebsd-questions)