Got command to Filter range of date from particular column of csv and but it does not work if both start and end date are same and input file has only one entry for that date

awk -v start="$start" -v end="$end" -F, '$2>=start && $2<=end' Inputfile 

works fine to filter date from 2nd column but if start="10/25/2017" and end="10/25/2017" and if the input file is (i.e only one entry for date "10/25/2017"), then no output is obtained


closed as off-topic by RomanPerekhrest, Stephen Rauch, peterh, Kusalananda, αғsнιη Oct 25 '17 at 9:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – RomanPerekhrest, Stephen Rauch, peterh, Kusalananda
If this question can be reworded to fit the rules in the help center, please edit the question.


I checked exacly your case and dat file. It works for me HOWEVER

  • AWK does not know date like this, so 9/30/2017 is higher than 10/1/2017. therefore the result could be very far from expected BECAUSE they are just strings!
  • "Military type timing", like 2017/09/30 and 2017/10/01 would work.
  • Separate month/day/year and compare them accordingly - but in this case I suggest perl rather than awk

Maybe it is a variable scope problem you have.

Try to use export start='10/25/2017' ; export end='10/25/2017' instead of start="10/25/2017" if you run awk in subshell for example.

  • Instead of the term "military type timing", you're looking for ISO 8601 -- en.wikipedia.org/wiki/ISO_8601#Calendar_dates – glenn jackman Oct 24 '17 at 21:14
  • @Glenn, I could have said "my timing" as well, because in Hungary we use this type of date... but you are abolutely true. – V-Mark Oct 24 '17 at 22:08
  • You are correct. Awk does not know about dates. This answer is what mislead the questioner. – Wildcard Oct 24 '17 at 23:08
  • @Wildcard LOOOL that "answer". There was also other, more correct answers... unfortunately with this date order a correct snippet is not an easy one-liner. – V-Mark Oct 25 '17 at 8:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.