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 ...
- 02-17-2009 #1Just 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
I only need somne,xyz,test,hello,Then i will pass it to dig/nslookup for more details of these domain.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
- 02-17-2009 #2Just 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 thisLast thing what i need is to remove _ax_ can any on do this with sed.Code:_ax_urname _ax_123 _ax_test _ax_hello
- 02-18-2009 #3Linux 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
- 02-18-2009 #4Just Joined!
- Join Date
- Sep 2008
- Posts
- 7
Yes thanks i have also figured it out
I have one more thing to doCode:awk -F"_" '{print $3}'
now i got my required string.Now i want to add a string on end of each line
Now i want thisCode:somename xyz test hello
somename.urhost
xyz.urhost
test.orhost
hello.urhost
can you guid me.
- 02-18-2009 #5Just Joined!
- Join Date
- Sep 2008
- Posts
- 7
I also got this working too

sed 's/$/urhost/' newdata.txt
- 02-18-2009 #6Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
No need to use sed to process the result from awk.sed 's/$/urhost/' newdata.txt
awk can handle it all (and well):
awk 'BEGIN{FS="[ _]+"} {print $3".urhost"}' data.txt


Reply With Quote