Find the answer to your Linux question:
Results 1 to 6 of 6
Hi All I have file which contain domain names.But this file also contain some extra info which i don't need.So need a way i can filter with sed,awk access info.Kindly ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    7

    Need filter in a file with sed,awk

    Hi All

    I have file which contain domain names.But this file also contain some extra info which i don't need.So need a way i can filter with sed,awk access info.Kindly can any one provide me help with this below is file

    Code:
    _ax_somename__info__Uptime_days	19	G	2009-02-17T14:36:12-05
    _ax_xyz__info__Uptime_days	5	G	2009-02-17T14:35:07-05
    _ax_test__info__Uptime_days	14	G	2009-02-17T14:36:06-05
    _ax_hello__info__Uptime_days	20	G	2009-02-17T14:36:02-05
    I only need somne,xyz,test,hello,Then i will pass it to dig/nslookup for more details of these domain.

  2. #2
    Just Joined!
    Join Date
    Sep 2008
    Posts
    7
    Hi Again

    I have figured out a way to do this but i am stuck on last thing you can help me now i am sure


    Code:
    cat data.txt  | awk -F" " '{print $1  }' | sed 's/[ __info__Uptime_days ]*$//'
    
    This will give me some thing like this
    Code:
    _ax_urname
    _ax_123
    _ax_test
    _ax_hello
    Last thing what i need is to remove _ax_ can any on do this with sed.

  3. #3
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    awk alone can handle this kind of task pretty well:
    Code:
    awk 'BEGIN{FS="[ _]+"} {print $3}' data.txt

  4. #4
    Just Joined!
    Join Date
    Sep 2008
    Posts
    7
    Yes thanks i have also figured it out

    Code:
    awk -F"_" '{print $3}'
    I have one more thing to do

    now i got my required string.Now i want to add a string on end of each line
    Code:
    somename
    xyz
    test
    hello
    Now i want this

    somename.urhost
    xyz.urhost
    test.orhost
    hello.urhost

    can you guid me.

  5. #5
    Just Joined!
    Join Date
    Sep 2008
    Posts
    7
    I also got this working too


    sed 's/$/urhost/' newdata.txt

  6. #6
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    sed 's/$/urhost/' newdata.txt
    No need to use sed to process the result from awk.
    awk can handle it all (and well):

    awk 'BEGIN{FS="[ _]+"} {print $3".urhost"}' data.txt

Posting Permissions

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