sed is great, but there are other tools for picking out fields in text strings.
echo "akd_fak_asdkf_jal" | gawk -F_ '{printf $1}'
echo "akd_fak_asdkf_jal" | cut -d_ -f1
Not that there are any wrong answers, but you should explore which tools fit
best in which usage scenarios. There is a wealth of applications you can use
in shell scripting. If you just focus on one or two great tools, you will lose
some of the power that comes with shell scripting.
-Michael
----- Original Message ----
From: Eduardo Sanz Garcia <[EMAIL PROTECTED]>
To: BYU Unix Users Group <[email protected]>
Sent: Monday, March 12, 2007 8:03:35 PM
Subject: Re: [uug] sed question
I found the reply to my own question:
echo "akd_fak_asdkf_jal" | sed -e "s/\(_.*\)//" ===> akd
Eduardo Sanz Garcia wrote:
>Now the *oposite* question:
>If I have a line like this "akd_fak_asdkf_jal" and I want the leading "akd"
>How can I do this using sed or other utilities?
>
>
>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
>>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
>
>
>
--------------------
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