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

Discussion in 'Perl' started by NNTP, Apr 6, 2004.

  1. NNTP

    NNTP Guest

    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?
    NNTP, Apr 6, 2004
    #1
    1. Advertising

  2. In article <>,
    NNTP <> wrote:
    >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

    ....
    >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?


    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 ""}
    Kenny McCormack, Apr 6, 2004
    #2
    1. Advertising

  3. (NNTP) wrote in message
    >
    > 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?
    >


    sed -e '/MAC/G' yourfile
    rakesh sharma, Apr 7, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NNTP

    sed awk or perl for this?

    NNTP, Sep 11, 2003, in forum: Perl
    Replies:
    13
    Views:
    3,461
    Alan Connor
    Sep 30, 2003
  2. gorda
    Replies:
    2
    Views:
    535
    Andrew Shitov
    Oct 21, 2003
  3. bolega
    Replies:
    6
    Views:
    2,009
  4. gorda
    Replies:
    3
    Views:
    141
    Barry Kimelman
    Oct 21, 2003
  5. NNTP
    Replies:
    4
    Views:
    157
    rakesh sharma
    Apr 7, 2004
Loading...

Share This Page