Per s g's linked answer from serverfault, passing -a
to grep
forces binary files to be treated as text files. Here is the detailed solution:
> grep -a -n 6307459 /disk2/user/test/logs/2015-03-31-23-42-52-7224.log 171560394:Rcvd client's reconnect count 6307459.
Using the found line number of 171560394
, I then created the following command to get a million lines starting at 100 lines before the found pattern so that I can view it in emacs:
> head -n 172560294 /disk2/user/test/logs/2015-03-31-23-42-52-7224.log \ | tail -n 1000000 > /disk2/user/test/logs/2015-03-31-23-42-52-7224.log_mid