rkc@XN.LL.MIT.EDU (rkc) (06/01/89)
I have a case where I want to delete, from a text file, something that looks like: /*name*/ ...lots of multiple line junk /*name*/ Everything between the /*name*/ AND both of the /*name*/ lines must be removed. Finally, name is a known specific name, but the multiple line junk varies from time to time. I cannot figure out how to write the regular expression, so if some SED/GREP guru can help me out (maybe with a short description of why it works) I'd really appreciate it. E-mail answers; I'll post if others are interested. Thanks, -Rob
bollella@ra.cs.unc.edu (Gregory Bollella) (06/03/89)
In article <1421@xn.LL.MIT.EDU> rkc@XN.LL.MIT.EDU (rkc) writes: >I have a case where I want to delete, from a text file, something that looks >like: > >/*name*/ >...lots of multiple line junk >/*name*/ > >Everything between the /*name*/ AND both of the /*name*/ lines must be >removed. Finally, name is a known specific name, but the multiple line junk >varies from time to time. I cannot figure out how to write the regular >expression, so if some SED/GREP guru can help me out (maybe with a short >description of why it works) I'd really appreciate it. >E-mail answers; I'll post if others are interested. > Thanks, > -Rob You should be able to use the following: sed /*name*/,/*name*/d < foo where the '/'s are required, the '*'s are part of your name as you indicated in your posting (and not necessary for sed) and foo is your file name. Short description: The (/*name*/,/*name*/) is an address given by two patterns. The 'd' just deletes all that the address indicates. Gregory Bollella bollella@cs.unc.edu Department of Computer Science CB# 3175 Sitterson Hall University of North Carolina Chapel Hill, NC 27599-3175
ark@alice.UUCP (Andrew Koenig) (06/04/89)
In article <1421@xn.LL.MIT.EDU>, rkc@XN.LL.MIT.EDU (rkc) writes: > I have a case where I want to delete, from a text file, something that looks > like: > /*name*/ > ...lots of multiple line junk > /*name*/ How about this? sed '/\/\*name\*\//,//d' <inputfile >outputfile -- --Andrew Koenig ark@europa.att.com
gregg@cbnewsc.ATT.COM (gregg.g.wonderly) (06/07/89)
From article <9429@alice.UUCP>, by ark@alice.UUCP (Andrew Koenig): > How about this? > > sed '/\/\*name\*\//,//d' <inputfile >outputfile Not to whine too loudly, but is it really necessary to make this look like magic? Just because you know that the RE routines take a NULL RE to mean 'use the last one specified', doesn't mean that such a 'feature' should always be exploited does it? Doesn't sed '/\/\*name\*\//,/\/\*name\*\//d' <inputfile >outputfile seem to be a slightly more educational solution to someone who asked for a solution, not knowing the answer? Not to pick on Andrew, I just hate incomplete examples without explanations for non-obvious things. -- ----- gregg.g.wonderly@att.com (AT&T bell laboratories)
gph@hpsemc.HP.COM (Paul Houtz) (06/09/89)
gregg@cbnewsc.ATT.COM (gregg.g.wonderly) writes: >Not to pick on Andrew, I just hate incomplete examples without explanations >for non-obvious things. Boy, you must hate Unix man entries, then!