With gawk (and probably the other awks as well):
$ echo akd_fak_asdkf_jal | gawk -F_ '{print "_" $NF}'
=> _jal
$ echo akd_fak_asdkf_jal_foo_bar | gawk -F_ '{print "_" $NF}'
=> _bar
-Michael
----- Original Message ----
From: Von Fugal <[EMAIL PROTECTED]>
To: [email protected]; [email protected]
Sent: Saturday, March 10, 2007 6:24:35 PM
Subject: Re: [uug] sed question
* Michael Brailsford [Sat, 10 Mar 2007 at 11:25 -0800]
<quote>
> I would use awk (or any of its various forms, such as gawk) for that.
>
> echo akd_fak_asdkf_jal | gawk -F_ '{print "_" $4}'
>
> Or even cut (though you will lose the char used as the delim):
>
> echo akd_fak_asdkf_jal | cut -f4 -d_
What if you want the last field, but it's not necessarily the 4th field?
Just curious.
Von Fugal
--------------------
BYU Unix Users Group
http://uug.byu.edu/
The opinions expressed in this message are the responsibility of their
author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG.
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
--------------------
BYU Unix Users Group
http://uug.byu.edu/
The opinions expressed in this message are the responsibility of their
author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG.
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list