hi all
i have a file in which first column has date in (yyyy-mm-dd) format and rest of the column has file information.
i want to write a program in such way that when i specify date i will get entries from that date till end of file.and there can be more than one entries for particular date.
in short i want to split file in 2 parts one part will have entries till date i have mentioned ( without date i have mentioned ) and other will have all entries from date i have mentioned till end of file. i am writing code in perl/shell script.
i am not getting how to do this till now..please suggest how this can be done ??
[LEFT]f is a variable, its name is arbitrary (it can be any valid variable name).
In Awk uninitialized variables have the numeric value zero.
When the first filed of the current record matches our pattern ($1==dt),
we set f to 1 (or any other number != 0 - for Awk 0 and null mean false,
all others mean true). We check every record
(first check, then set, so the record that matches
is not printed), we print the records once the variable is set to 1 (true).[/LEFT]
It goes like this:
dt="2007-10-19"
record: 2007-10-18
code: f
action: checks f is not 0 -> f==0 (uninitialized yet) -> do nothing
code: $1==dt{f=1}
action: $1!=dt -> do nothing
record: 2007-10-19
code: f
action: checks f is not 0 -> f==0 (uninitialized yet) -> do nothing
code: $1==dt{f=1}
action: $1==dt -> set f to 1(true) --> initialized here!
record: 2007-10-20
code: f
action: checks f is not 0 -> f==1 -> default action: print the current record
code: $1==dt{f=1}
action: $1!=dt -> do nothing (even if $1==dt, we will set again f to 1,
but it doesn't matter :)