[nSLUG] sed question
jason at ohm.ath.cx
Thu Dec 29 04:08:36 AST 2005
> While sed is good I have found awk to be better. Most problems solved
> with sed can be solved with awk just as easily. It is still good to
> know sed syntax as the vi/vim ex mode (: mode) syntax is similar.
Well, they are intended for different things... Awk is very good for
processing delimited files, as here.
Some might even suggest perl makes them both obsolete?
Herb: You need to use the -e switch I think to run on the command line.
Also, I don't think sed understands \s, like perl does.
so, sed -e 's/^\(EMAIL:[ \t]*[^ \t]*\).*$/\1/'
is probably closer to what you are looking for (although this matches any
whitespace after :, and the address doesn't necessarily have to end in
Of course it makes more sense to use awk for this particular task, as
Your expression might also contain a logic flaw, I can never remember
whether + is a greedy match or not, but if it is .+ will match to the end of
the line, which is cleary not what you want there.
More information about the nSLUG