Date Compare



I have a list like this............





5758M 65.3 427 Feb 9 23:00:00
5800M 64.3 424 Feb 9 23:15:00
5875M 94.1 426 Feb 9 23:30:00
5938M 95.1 427 Feb 9 23:45:00
5991M 46.2 436 Feb 10 00:00:00
6051M 55.8 429 Feb 10 00:15:00
6051M 72.2 429 Feb 10 00:30:00
6056M 82.0 423 Feb 10 00:45:00
7876M 63.3 416 Feb 11 22:45:00
7617M 53.9 420 Feb 11 23:00:00
7658M 42.5 415 Feb 11 23:15:00
7727M 79.8 419 Feb 11 23:30:00
7786M 88.6 419 Feb 11 23:45:00
7790M 49.1 430 Feb 12 00:00:00
7749M 36.0 421 Feb 12 00:15:00
7774M 56.8 418 Feb 12 00:30:00
7649M 58.3 414 Feb 12 00:45:00
............................
.....................
........................................



I have to extract only a limited date parameters with comparison to my
$1 and $2 ,

The script runs like this

../myscript "Feb-9" "Feb-11"

I can use "tr" to change the "Feb-9" to " Feb 9" ( without "-" )
or is there any way out to compare the dates I am pasting the
incomplete script in this message.
=============================================================
#!/bin/bash
# Get the name os source file as it is the third arguements.
usage() {
echo "$0: start-date: `date |cut -d" " -f2,3`
end-date: `date -d "+10 day"|cut -d" " -f 2,3` filename"
exit 0
}

if test $# -eq 3
then
START_DATE=`echo "$1"|tr "A-Z" "a-z"`
END_DATE=`echo "$2"|tr "A-Z" "a-z"`
SOURCE=`echo "$3"|tr "A-Z" "a-z"`
elif test $# -eq 2
then
START_DATE="$1"
END_DATE="$2"
SOURCE="all.stats"
else
usage
fi


# Convert the " " to "-" for later if-else comaprison.

_START_DATE=`echo "$START_DATE"|tr " " "-"`
_END_DATE=`echo "$END_DATE"|tr " " "-"`

# Set the name of destination file as it will contain the spanned
date's data.
_STATS_FILE="stats-$_START_DATE-$_END_DATE"

# the loop reads the data file and every input line is verified for
paramteres.
cat "$SOURCE" |while read line
do
THE_DATE=`echo $line|awk '{ print $4,$5 }'`
if test "$THE_DATE" >= "$START_DATE" -a "$THE_DATE" <= "$END_DATE"
then
do-something
fi


here is the actual comparison that I need to identify and clear, I want
that the START-DATE should be compared first and then END-DATE and if
soemthing matches , then it should extract that line.


Any Idea?


Regards,
Moody
PTML

.



Relevant Pages

  • Re: sort files by exif date
    ... >> and the filenames in a list, sort, then extract the filenames again. ... >> Probably a few lines of shell script. ... That string will be a line of text. ...
    (comp.unix.questions)
  • Assistance needed with script.......
    ... have a somewhat simple script, ... I would like to parse from the data file, such as Front Director Paths, ... Device Emulation Type: FBA ... Device Defined Label Type: N/A ...
    (perl.beginners)
  • Re: HTML - Extract Specific Text
    ... etc.) that can be used in any calculation. ... imported text is standardised you can easily extract whatever you want. ... a VBA script. ... and then takes the 11 characters starting with the fourth ...
    (comp.databases.filemaker)
  • Re: another frustrating learner question, CLOS
    ... processing a data file in a one time script? ... The meat of Erik message is that the problems that have this kind of ... That's what I do all day, every day, because management needs reports, ... you put them in a script to generate ...
    (comp.lang.lisp)
  • Strange IO Error when extracting zips to a network location
    ... I've written a script to run on windows to extract all zips under a given directory path to another directory path as such: ... python extractzips.py ... The purpose of this script is to retrieve backup files which are individually zipped under a backup directory tree on a backup server. ... When I extract the same tree to my local drive it works fine without error. ...
    (comp.lang.python)