You are not logged in.
Pages: 1
Hello
I have an interesting problem
I have a scheduling software which outputs a iCalendar file - this iCalendar file can be read by Kontact but all the events have NO alarm
I Checked the file and what I need to add is :
BEGIN:VALARM
DESCRIPTION:
ACTION:DISPLAY
TRIGGER;VALUE=DURATION:-PT15M
END:VALARM
before
END:VEVENT
problem is that
1) the scheduling software exports the file often - so any modification would be overwritten - which means I have to have the script run periodically
2) the script shouldn't run more than once on the file otherwise I would get multiple alarm tags...
what I though of doing is
check for
TZID:America/Toronto
END:VEVENT
and replace it with
TZID:America/Toronto
BEGIN:VALARM
DESCRIPTION:
ACTION:DISPLAY
TRIGGER;VALUE=DURATION:-PT15M
END:VALARM
END:VEVENT
which should prevent all problems.
Now the big problem is that I have not found a single way around to have a script doing this for me.
I have tried sed but it doesn't support multiple lines
I have tried awk which is able to insert multile lines but somehow cannot search for multiple lines
The added complication is that I have a lot of special characters in the text to search and replace
any of you good souls can help me with this???
Cippa
Offline
This should work:
#!/bin/bash
INSERT='BEGIN:VALARM\nDESCRIPTION:\nACTION:DISPLAY\nTRIGGER;VALUE=DURATION:-PT15M\nEND:VALARM'
sed -e "/TZID:America\/Toronto$/N;s/\(TZID:America\/Toronto\)\n\(END:VEVENT\)/\1\n$INSERT\n\2/" $1
I just learned from http://www.shell-fu.org/lister.php?id=539
Offline
Pages: 1