0

I tried

awk '$6 ~ /^2017-04-01/,/^2017-04-11/' filename

and another way

awk '$6~/^2017-07-04/, $6~/^2017-07-10/' filename

But it displayed all month data. what changes should done to filter range dated files.

ghoti
  • 45,319
  • 8
  • 65
  • 104
  • format your question, see https://stackoverflow.com/editing-help... add sample input data and expected output... see also https://stackoverflow.com/questions/38972736/how-to-select-lines-between-two-patterns for using flags – Sundeep Nov 13 '17 at 09:34
  • Can you please include some sample input data, along with the results you are getting and the results you are looking for, based on that sample? It's very hard to diagnose your problem if we don't have a problem example that can be replicated. – ghoti Nov 13 '17 at 14:50

1 Answers1

1

you can write it this way

awk '"2017-04-01" <= $6  && $6 <= "2017-04-11"'  file

for regex you should implement the range as patterns

awk '$6~/^2017-04-(0[1-9]|1[01])/' file

however, I think the first alternative is cleaner, faster as well.

karakfa
  • 66,216
  • 7
  • 41
  • 56