Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

awk (or cut) to process from right to left?

1,002 views
Skip to first unread message

jessica6

unread,
Sep 25, 2008, 2:36:59 PM9/25/08
to
Is it possible to process lines from right to left instead of the
default left to right?

I'm trying to strip off the main domains from a list, ie:

ads.zedo.com
c1.zedo.com
c2.zedo.com
c3.zedo.com
foo.bar.zedo.com
c4.zedo.com
c5.zedo.com
zedo.com
blast.thing.duh.c6.zedo.com
c7.zedo.com
c8.zedo.com
d3.biz.frack.zedo.com
d3.zedo.com
d7.zedo.com

I was trying to pipe the above through awk or cut, such that I get 14
zedo.com returned:

If I could parse from right to left, with "." delimiter, I'd have my
list. But I'm curious if that is possible.

Help would be great.

Thanks!


pk

unread,
Sep 25, 2008, 2:48:26 PM9/25/08
to

IIUC, just do

awk -F'.' -v OFS='.' '{print $(NF-1),$NF}' file

jessica6

unread,
Sep 25, 2008, 3:04:59 PM9/25/08
to

That's it! Exactly what I needed. Thanks!

0 new messages