From: Al Aab <af137@freenet.toronto.on.ca>
Sent: 16 September 1996 20:25
=========================== seders newsletter #5 ===============================
Here is a sed problem for sharp seders.
The original motivation for this hit while reading a post on comp.unix.editor.
The poster wanted to extract the first field of a UNIX password file. His
problem could be handled with sed, of course, but even primitive sed would be
an overkill. cut would not.
Using a 2-line input file, and sed15 for DOS, I did the following. Can you
comment on the subtle differences between the different sed scripts?
sed "p;s/:[^:]+:/----/1" d
ab:abc:abd:....
ab----abd:....
:xyz::xyy::xxx::zzz:
----:xyy::xxx::zzz:
sed "p;s/:[^:]+:/----/2" d
ab:abc:abd:....
ab:abc:abd:....
:xyz::xyy::xxx::zzz:
:xyz:----:xxx::zzz:
sed "p;s/:[^:]+/----/2" d
ab:abc:abd:....
ab:abc----:....
:xyz::xyy::xxx::zzz:
:xyz:----::xxx::zzz:
========================= end of seders newsletter #5 ==========================