Search code examples
design-patternssedicalendar

SED delete specific lines between two patterns?


I am trying to filter an *.ics file using sed. The *.ics file looks like this:

[...]

BEGIN:VEVENT
UID:0xfoo
SUMMARY:foo
DTSTART:20131212T090000
DTEND:20131212T100000
SEQUENCE:0
DTSTAMP:20131212T100000
LOCATION:foo
CATEGORIES:foo
DESCRIPTION:foo
CLASS:PUBLIC
END:VEVENT

[...]

I want to delete lines starting e.g. with UID or SEQUENCE, but only if they are between BEGIN:VEVENT and END:VEVENT

I tried to delete these lines with:

sed '/^BEGIN:VEVENT/,/^END:VEVENT/ /^UID/d'

But it will only return an error saying something like unknown command '/'

How is it possible to delete these lines?

Thanks!


Solution

  • try this line:

     sed '/^BEGIN:VEVENT/,/^END:VEVENT/{/^\(UID\|SEQUENCE\)/d}' file