in reply to How to duplicate lines

$ echo "ip vrf forwarding ABC:Defgh ip address 1.1.1.1 255.255.255.252 ip vrf forwarding ABD: Efghi ip address 2.2.2.2 255.255.255.252" | perl -pe'$_ .= $_ if /^ip addres +s/' ip vrf forwarding ABC:Defgh ip address 1.1.1.1 255.255.255.252 ip address 1.1.1.1 255.255.255.252 ip vrf forwarding ABD: Efghi ip address 2.2.2.2 255.255.255.252 ip address 2.2.2.2 255.255.255.252

Replies are listed 'Best First'.
Re^2: How to duplicate lines
by ddrew78 (Beadle) on Mar 03, 2010 at 23:30 UTC
    Thanks to everyone for the quick responses. However, I made a crucial mistake when I showed what it needs to become. What I actually need to change it to needs to be
    ip vrf forwarding ABC:Defgh ip address 1.1.1.1 255.255.255.252 ip address 1.1.1.1 255.255.255.100 ip vrf forwarding ABD: Efghi ip address 2.2.2.2 255.255.255.252 ip address 2.2.2.2 255.255.255.100
    The last part of the duplicated line needs to change as it is being copied. Is there any way of doing this?
      Change the code given above to:

      perl -pe'$_ .= $_, s/252$/100/  if /^ip address/'