add blank lines after word MAC (sed/awk or perl??)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NNTP

    add blank lines after word MAC (sed/awk or perl??)

    I have a file with the following data

    192.168.60.161 DOMAINNAME-POWER 03U
    192.168.60.161 DOMAINNAME-TEMP 1eU
    192.168.60.161 MAC 00-xy-zz-07-bd-8a
    192.168.60.179 DOMAINNAME-abacdf 00U
    192.168.60.179 DOMAINNAME 00U
    192.168.60.179 DOMAINNAME-abacdf 20U
    192.168.60.179 DOMAINNAME 1eU
    192.168.60.179 MAC 00-xy-8b-1c-08-c7
    192.168.60.198 DOMAINNAME-abcd 00U
    192.168.60.198 DOMAINNAME 1cU
    192.168.60.198 DOMAINNAME 00U
    192.168.60.198 DOMAINNAME-abcd 20U
    192.168.60.198 DOMAINNAME 1bU
    192.168.60.198 DOMAINNAME 1eU
    192.168.60.198 DOMAINNAME 1dU
    192.168.60.198 MAC 00-zz-aa-bb-8f-35


    what I want to do is add blank line after MAC entry for each IP. I am
    confortable with awk/sed but can't seem to fig. this out.

    do I need perl? or can sed/awk do this?
  • Kenny McCormack

    #2
    Re: add blank lines after word MAC (sed/awk or perl??)

    In article <110fc16.040406 0748.4752f092@p osting.google.c om>,
    NNTP <news8080@yahoo .com> wrote:[color=blue]
    >I have a file with the following data
    >
    >192.168.60.1 61 DOMAINNAME-POWER 03U
    >192.168.60.1 61 DOMAINNAME-TEMP 1eU
    >192.168.60.1 61 MAC 00-xy-zz-07-bd-8a
    >192.168.60.1 79 DOMAINNAME-abacdf 00U
    >192.168.60.1 79 DOMAINNAME 00U[/color]
    ....[color=blue]
    >what I want to do is add blank line after MAC entry for each IP. I am
    >confortable with awk/sed but can't seem to fig. this out.
    >
    >do I need perl? or can sed/awk do this?[/color]

    I don't understand the reference to this mythical language called sed/awk.
    Wouldn't it make just as much sense to ask if it could be done in
    Fortran/Python?

    Anyway, in AWK (2 liner):

    1
    /MAC/ {print ""}

    Comment

    • rakesh sharma

      #3
      Re: add blank lines after word MAC (sed/awk or perl??)

      news8080@yahoo. com (NNTP) wrote in message[color=blue]
      >
      > I have a file with the following data
      >
      > 192.168.60.161 DOMAINNAME-POWER 03U
      > 192.168.60.161 DOMAINNAME-TEMP 1eU
      > 192.168.60.161 MAC 00-xy-zz-07-bd-8a
      > 192.168.60.179 DOMAINNAME-abacdf 00U
      > 192.168.60.179 DOMAINNAME 00U
      > 192.168.60.179 DOMAINNAME-abacdf 20U
      > 192.168.60.179 DOMAINNAME 1eU
      > 192.168.60.179 MAC 00-xy-8b-1c-08-c7
      > 192.168.60.198 DOMAINNAME-abcd 00U
      > 192.168.60.198 DOMAINNAME 1cU
      > 192.168.60.198 DOMAINNAME 00U
      > 192.168.60.198 DOMAINNAME-abcd 20U
      > 192.168.60.198 DOMAINNAME 1bU
      > 192.168.60.198 DOMAINNAME 1eU
      > 192.168.60.198 DOMAINNAME 1dU
      > 192.168.60.198 MAC 00-zz-aa-bb-8f-35
      >
      >
      > what I want to do is add blank line after MAC entry for each IP. I am
      > confortable with awk/sed but can't seem to fig. this out.
      >
      > do I need perl? or can sed/awk do this?
      >[/color]

      sed -e '/MAC/G' yourfile

      Comment

      Working...