0

I have a large log file (28MB) that I'm trying to run some queries on. I've noticed any time I try to grep a particular minute in the file, the output overruns into the following minute before stopping.

>> grep 'T19:54' aws_elb.log | awk '{print $2}'
...
2021-06-10T19:54:59.934622Z
2021-06-10T19:54:59.938837Z
2021-06-10T19:54:59.946078Z
2021-06-10T19:54:59.957267Z
2021-06-10T19:54:59.965747Z
2021-06-10T19:55:00.017838Z
2021-06-10T19:55:00.017989Z
2021-06-10T19:55:00.048256Z
2021-06-10T19:55:00.057552Z
2021-06-10T19:55:00.070085Z
2021-06-10T19:55:00.073510Z
2021-06-10T19:55:00.073589Z
2021-06-10T19:55:00.084122Z
2021-06-10T19:55:00.103200Z
2021-06-10T19:55:00.106992Z
2021-06-10T19:55:00.186963Z
2021-06-10T19:55:00.236496Z

I'm stumped. Is this an issue with the file size?

1
  • what's the output with just the grep and without the awk? And should we assume you want to match only on those timestamps? Commented Sep 20, 2021 at 21:24

1 Answer 1

3

There will probably be a T19:54 at another place in the line considering that you are printing just a section of it with awk.

Consider going the other way around:

awk '{print $2}' aws_elb.log | grep 'T19:54' -
2
  • 4
    or drop the grep: awk '$2 ~ "T19:54" { print $2 }' (or even awk '{$0=$2} /T19:54/') Commented Sep 20, 2021 at 21:29
  • 1
    Great tips. I will learn about awk someday. Commented Sep 20, 2021 at 21:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.