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

sed-a-mental journey

2 views
Skip to first unread message

Jeff Hyman

unread,
May 14, 2009, 5:42:50 PM5/14/09
to
# Remove everything left of the first character after the "@".
# your_...@domain.com
# ^^^^^^^^^^^
# domain.com <- desired results.

echo "your_...@domain.com" | sed -e 's/your_email@//' # Works
# echo "your_...@domain.com" | sed -e 's/*@//' # Nope
# echo "your_...@domain.com" | sed -e 's/*@#//' # Nope displays all
# echo "your_...@domain.com" | sed -n 's/*@#//' # Nope displays none
exit
Question: How do I tell 'sed' that everything to the left of the
asterisk, including the asterisk, are to be replaced with
nothing?
... or ...
how can an asterisk be interpreted as a true wildcard and
not the actual character itself within sed?

I know I have one of Stocklers awkaholic scripts around here somewhere,
but I wouldn't understand it anyway. I miss being able to call him on
these type of simple questions.

Anyway... As always... TIA!
- Jeff H

Jean-Pierre Radley

unread,
May 14, 2009, 6:02:48 PM5/14/09
to
Jeff Hyman typed (on Thu, May 14, 2009 at 05:42:50PM -0400):

Bobby would have cringed, since anytime sed was more efficient then awk,
his mouth would twitch. He knew awk backwards and forward, but had an
unjustified hatred of sed.

Your sed man page would quickly disclose that the asterisk is no
kind of wildcard in sed (nor in awk, for that matter). In regular
expressions, the asterisk means "any number of". The `.' stands for any
character. So `.*' in a regexp mean 0, 1 or many of anything. Thus what
you want is:

echo your_...@domain.com | sed 's/.*@//'

--
JP

mbennett

unread,
May 15, 2009, 9:30:06 AM5/15/09
to
On May 14, 5:02 pm, Jean-Pierre Radley <j...@jpr.com> wrote:
> Jeff Hyman typed (on Thu, May 14, 2009 at 05:42:50PM -0400):
> | # Remove everything left of the first character after the "@".
> | #       your_em...@domain.com

> | #       ^^^^^^^^^^^
> | #                  domain.com    <- desired results.
> |
> |   echo "your_em...@domain.com" | sed -e 's/your_email@//'  # Works
> | # echo "your_em...@domain.com" | sed -e 's/*@//'           # Nope
> | # echo "your_em...@domain.com" | sed -e 's/*@#//'          # Nope displays all
> | # echo "your_em...@domain.com" | sed -n 's/*@#//'          # Nope displays none

> | exit
> | Question:  How do I tell 'sed' that everything to the left of the
> |            asterisk, including the asterisk, are to be replaced with
> |            nothing?  
> |            ... or ...
> |            how can an asterisk be interpreted as a true wildcard and
> |            not the actual character itself within sed?
> |
> | I know I have one of Stocklers awkaholic scripts around here somewhere,
> | but I wouldn't understand it anyway.  I miss being able to call him on
> | these type of simple questions.
> |
> | Anyway... As always... TIA!
>
> Bobby would have cringed, since anytime sed was more efficient then awk,
> his mouth would twitch.  He knew awk backwards and forward, but had an
> unjustified hatred of sed.
>
> Your sed man page would quickly disclose that the asterisk is no
> kind of wildcard in sed (nor in awk, for that matter). In regular
> expressions, the asterisk means "any number of".  The `.' stands for any
> character.  So `.*' in a regexp mean 0, 1 or many of anything.  Thus what
> you want is:
>
>         echo your_em...@domain.com | sed 's/.*@//'
>
> --
> JP

JP

I remember Bob Stockler from years ago. What happened to him?

Mark

Jeff Hyman

unread,
May 15, 2009, 11:54:08 AM5/15/09
to
Jean-Pierre Radley typed (on Thu, May 14, 2009 at 06:02:48PM -0400):

Thank you JP.
- That did the trick and thanks for the
explaination as to what made it work.

- Jeff H

Jean-Pierre Radley

unread,
May 15, 2009, 1:45:59 PM5/15/09
to
mbennett typed (on Fri, May 15, 2009 at 06:30:06AM -0700):

|
| I remember Bob Stockler from years ago. What happened to him?

He passed away in January.

--
JP

mbennett

unread,
May 18, 2009, 9:58:14 AM5/18/09
to

JP

I really regret hearing that. I subscribed to The Guru magazine which
John Esak published, and still have every copy. Bob Stockler had a
regular column about awk and I was always in awe of the depth of his
knowledge, as were many others I'm sure.

I know you had articles there on a regular basis as well, as did
several other contributors. In case nobody ever said "Thank You",
allow me to say it now. I appreciate it still, and continue to dig
out the copies I have on occasion and refer to them.

Mark

Jean-Pierre Radley

unread,
May 18, 2009, 12:46:35 PM5/18/09
to
mbennett typed (on Mon, May 18, 2009 at 06:58:14AM -0700):

Thank you, Mark.

I really miss Bob a lot. We used to be on the phone with each other every
ten days or so.

--
JP

0 new messages