dw at

Any quick tips on removing everything from a log file before a certain time? The log file is 3.1GB. My analysis tool handles the size fine, but there is a lot of extraneous stuff in there
ok, using split

dw at 2018-10-02T16:02:14Z

clacke@libranet.de ❌ likes this.

For occasions like this, sed -n can come in handy. With sed -n, sed doesn't print anything on output by default, so you can make a command that prints certain lines, like a sort of overpowered grep:

$ printf '12:23:00 foo\n13:45:23 bar\n15:43:12 baz\n' |
  sed -ne '/^13:/,$p'
13:45:23 bar
15:43:12 baz

/^13:/,$ means "for the lines starting with the line that starts with 13: and ending with the end of the file", and p means "print".

In other words, print the part of the file that starts with the line that matches the regex. In the example, "foo" came before the "13:" line, so it wasn't printed.

clacke@libranet.de ❌ at 2018-10-03T15:21:07Z

#HPREp Using sed as an overpowered grep

clacke@libranet.de ❌ at 2018-10-04T02:14:53Z

dw likes this.