Re: shell script to parse html and date comp ?

Jiří Baum <[email protected]>
Newsgroups gmane.org.user-groups.slug.general
Message-ID <[email protected]>
Hi,

Voytek:
> I would like to fetch date/time from html file, and use date comparison
> and make an ics/vcal file eventually

Hmm, sounds like you might want to use a different programming language,
like python, perl or something, rather than just a shell script. It can
be done in shell script, but it'll be advanced shell scripting, while it
would be fairly basic python or perl or whatever.

> the date comes as so:

> <tr><td colspan="1" rowspan="1">Start Date Time: </td><td colspan="1"
> rowspan="1">20/03/2014 1400 Thursday</td></tr>

> is 'grep -o' the way to go ? what regex do I need where I put ???? ?

You might want to use "grep" first to get the correct lines out, so
you're not doing multiple things in one command, then either grep -o to
get the date out, or the cut command.

Something like:

grep 'Start Date Time' | cut -d '>' -f5 | cut -d '<' -f1

> what do I need to do with date to be able to compare it to a date range?

You have two options here:

* convert it to an integer, with the date command (date -d $x +%s), then
work with them as integer number of seconds, or

* touch a temporary file, again with the -d option, then check which
file is older.


Cheers

Jiri
-- 
Jiří Baum <[email protected]>
Sabik Software Solutions Pty Ltd
0413 183 117
http://www.baum.com.au/sabik
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.