[OT] can sed handle this situation? (might require variable)

Zhang Weiwu zhangweiwu at realss.com
Sun Apr 15 08:29:50 UTC 2007


On Sun, 2007-04-15 at 01:40 -0400, Parv wrote:
> in message <1176603461.20274.12.camel at joe.realss.com>,
> wrote Zhang Weiwu thusly...
> >
> > Dear list. I could not find a mailing list about 'sed' (there is
> > an very inactive Yahoo Group though) so I wish to try some luck
> > here.
> 
> Try, comp.unix.misc newsgroup.
> 
> 
> > I've got a situation that looks like require using variable and
> > not possible to process with sed. But I am not sure. Can someone
> > suggest me if this task is out of scope of sed?
> 
> Try some variation of what Garret suggested if sed is the
> requirement and skip rest of the message.

Thank you very much for all of you providing insights. I have not yet
tried all possibilities in sed but I have just discovered it's
relatively easy to handle this task in awk with this script:

/^$/ { print "createTimestamp:", timeStamp; timeStamp = ""; }
/^ahkCreateTimeStamp:/ { timeStamp = $2;}
/^createTimestamp:/ { if (timeStamp == "") timeStamp = $2; }

$0 !~ /^ahkCreateTimeStamp:/ && $0 !~ /^createTimestamp:/ {
	print;
}



More information about the freebsd-questions mailing list