Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, i have a cisco config file looking like this (in part): Code: object-group network First_DNS description First DNS servers network-object host 21x.x.x.x network-object host 21x.x.x.x network-object host 21x.x.x.x ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    6

    arrange blocks of text in single lines


    Hi all,

    i have a cisco config file looking like this (in part):

    Code:
    object-group network First_DNS
     description First DNS servers
     network-object host 21x.x.x.x
     network-object host 21x.x.x.x
     network-object host 21x.x.x.x
    object-group network 2nd_DNS
     description 2nd DNS servers
     network-object host 8x.x.x.x
     network-object host 8x.x.x.x
    object-group network Internet_DNS
     group-object First_DNS
     group-object 2nd_DNS
    object-group network Partner_IN
     description A number of OpenVMS-systems to be administered by partner via VPN IPsec-klienter
     network-object host 10.240.3.202
     network-object host 10.240.3.245
     network-object host 10.240.3.247
    object-group network Partner_OUTSOURCE
     description A number of OpenVMS-systems to be administered by partner
     network-object host 19x.x.x.x
     network-object host 19x.x.x.x
     network-object host 172.22.2.11
     network-object host 172.16.16.19
    access-list in_blabla extended permit xxxx
    access-list in_blabla extended permit xxxx
    I want to get the object-group blocks separate single semicolon separated lines instead, like this:
    Code:
    object-group network First_DNS ; network-object host 21x.x.x.x ; network-object host 21x.x.x.x ; network-object host 21x.x.x.x
    
    object-group network 2nd_DNS ; network-object host 8x.x.x.x ; network-object host 8x.x.x.x
    
    and so on...
    Note that I dont need/want the description line in the result. Google has helped me to some extent with this, but my skills with awk (which seem to be the tool for the job) is limited. Any help will be greatly appreciated!

    //Adam

  2. #2
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    Awk is a tool suited for CSV-like text files. Try sed! There are several good easily findable examples in the internets if you search for "sed replace newline".

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    6
    Quote Originally Posted by Kloschüssel View Post
    Awk is a tool suited for CSV-like text files. Try sed! There are several good easily findable examples in the internets if you search for "sed replace newline".
    well, if it was only replacing newlines then i would use sed or tr, but this is a bit more complicated and as i said, googling has not helped me so far. Maybe sed is better than awk for this job, but i am hoping for some real examples here to help me get forward.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •