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_
----- Original Message ----
From: Eduardo Sanz-Garcia <[EMAIL PROTECTED]>
To: BYU Unix Users Group <[email protected]>
Sent: Friday, March 9, 2007 6:54:06 PM
Subject: Re: [uug] sed question
Thank you Joshua.
It works well.
The command was not simple. It seems that you know a lot about regular
expression.
How did you learn regular expression and/or sed? Any suggested book?
Joshua Draper wrote:
If you know want the text "_jal", you can use line below. I saved
your text string in a file called testsed.
$ sed -e "s/.*\(_jal\)/\1/" testsed
If you want the "_jal" because it is the last group of letters, then
you could use the following line.
$ sed -e "s/.*\(_.*\)/\1/" testsed
both commands return the following output:
_jal
Joshua Draper
On Mar 9, 2007, at 2:02 PM, Eduardo Sanz García wrote:
A sed question:
I have a line like this "akd_fak_asdkf_jal" and I want the trailing
"_jal".
How can I do this using sed or other utilities?
Thank you.
--------------------
BYU Unix Users Group
[1]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: [2]http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
--------------------
BYU Unix Users Group
[3]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: [4]http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
References
1. http://uug.byu.edu/
2. http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
3. http://uug.byu.edu/
4. 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
--------------------
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