1) Is there anyway to get the number of lines in a text file without having to scan through the whole file?
2) How do I compare if a date falls in between a starting date with a duration. eg. Starting date = 1st March Duration 5 days. check if a user entered date falls in between it.
1) there's a command in unix wc -l that returns #lines
2) check if users enter the starting month
check if the date occurs during the duration date
IF month_input == month_start
IF date_input >= date_start AND date_input =< date_end
THEN date input falls within the duration date
1) not that I know of
2) use month numbers, not month names, then set up the protocol yourself. Use pencil and paper. Here's a general outline of how I would do it.
obtain start date
loop five times through starting at start date
advance date 1 day at a time
if given date equals any of the five given dates in loop then it falls inside the loop.
advance date protocol:
if month == 1 && date == 31 advance month by 1 and date = 1;
else if month == 2 && not leap year days == 28 advance month by 1 and date = 1;
else if month == 12 && date == 31 then advance year by 1 and date and month = 1;
else advance date by one
leap year protocol:
you can look it up