I have a table with 10 columns. One of them is a date column and I want to get data for a specific date range. For example, I have data from the year 2016 and onwards, but I want to fetch data only for the duration 01/01/2018 to 12/31/2018. Is it possible to get this data using awk command?

closed as too broad by glenn jackman, Archemar, msp9011, Mr Shunz, nwildner Mar 20 at 16:53

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


You can reformat the date in a more useful (and less ambiguous) YYYY/mm/dd format and use string comparison.

awk -v date_column=8 '
   {date = substr($date_column, 7, 4)"/"substr($date_column, 1, 5)}
   date >= "2018/01/01" && date <= "2018/12/31"'

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