Find the answer to your Linux question:
Results 1 to 2 of 2
I am trying to extract a name and an IP address out of this excerpt. The container starts with ': (' where the previous line only contains ')'. The Name ...
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    1

    Help with matching

    I am trying to extract a name and an IP address out of this excerpt. The container starts with ': (' where the previous line only contains ')'. The Name is the first line in this container while the IP I am looking for is on the line with valid_ipaddr.

    Can someone point be in the right direction using perl or some other method?


    : (TNB-208.217.213.25
    :AG (false)
    :add_adtr_rule (false)
    :cp_products_installed (false)
    :enforce_gtp_rate_limit (false)
    :firewall (not-installed)
    :floodgate (not-installed)
    :gtp_rate_limit (2048 )
    :ipaddr (208.217.213.25)
    :type (host)
    )
    : (WEB-10.7.100.150
    :AG (false)
    :netobj_adtr_method (adtr_static)
    :the_firewalling_obj (
    :type (refobj)
    :refname ("#_All")
    )
    :valid_ipaddr (208.254.130.70)
    :add_adtr_rule (true)
    :cp_products_installed (false)
    :enforce_gtp_rate_limit (false)
    :firewall (not-installed)
    :floodgate (not-installed)
    :gtp_rate_limit (2048 )
    :ipaddr (10.7.100.150)
    :type (host)
    )

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    using awk's "range pattern" to select the name/addr, I
    clean up w/ sed:


    awk '/^\)/,/:/ { print $2 }' < data | sed '/^$/d ; s/(//g ; s/)//g'
    the sun is new every day (heraclitus)

Posting Permissions

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