sed : match one pattern then the next consecutive second pattern not working

Ive used this snippet of code on a solaris box thousands of times.
But it isnt working on the new linux box

sed -n '/interface LoopBack0/{N;/ ip address /p;}' *.conf

its driving me nuts !!

Is there something Im missing ?

What do you mean by not working? Any errors?

By the way, that command might not always do what you desire. It will print the last line of one file and the first line of the next file, if that particular condition is met.
This may not be desired. It is also possible that such a situation is improbable. I don't know your requirements, so I can only guess/suggest.

server> sed -n "/interface Loopback/{N;/ ip address /p;}" *.conf
server> 

Its not finding those lines. No errors. Im sure the lines exist, I double checked a few files. (pretty common config anyway .. )

I also tried to use ' instead of "

I did have a typo ... the B in loopback should have been lower but that change didnt make a difference.

Could you show/post input sample/s? That will make things a lot better.

The file would look like this

interface Loopback0
description ny to miami
ip address 10.11.12.13 255.255.255.255
!
interface Loopback39
description ny to dallas
ip address 10.14.15.16 255.255.255.252
!
interface Loopback786
description ny to los angeles
ip address 10.17.18.19 255.255.255.255

there may or may not be lines following the ip address lines.

this is the actualy excution of the code

server> sed -n "/interface Loopback/{N;/ ip address /p;}" *.conf
server>

This is the system Im using.
Linux Server 2.6.32-358.2.1.el6.x86_64 Wed Mar 13 00:26:49 UTC 2013 x86_64 GNU/Linux

.. and the distribution Im running
Distributor ID: CentOS
Description: CentOS release 6.4
Release: 6.4

Thanks in advance

---------- Post updated 06-21-13 at 09:04 AM ---------- Previous update was 06-20-13 at 01:38 PM ----------

No ideas ?

ip address never occurs on the line immediately following the interface line, so you should not expect any output.

Regards,
Alister

Not sure it's what you're looking for but the following short Perl one-liner can approach it :

%perl -ne 'chomp $_ ; print if /^interface/ ; print "\t$_\n" if /^ip/'  file

interface Loopback0     ip address 10.11.12.13 255.255.255.255
interface Loopback39    ip address 10.14.15.16 255.255.255.252
interface Loopback786   ip address 10.17.18.19 255.255.255.255

As alister says, there's a line between loopback and ip address . And, ip address does not have a space in front of it. To get sth like the output you are used to on your old system, try

sed -n "/interface Loopback/{h;n;n;/ip address/H;x;p}" *.conf