Linux – Grep in a huge log file (>14 GB) only the last x GB

greplinuxlog-files

I need to search something in a huge log-file (over 14 GB). I'm pretty sure it's in the last 4 GB or so.

Is there a way to skip the first X GB to speed things up?

Best Answer

I guess you could use tail to only output that last 4GB or so by using the -c switch

-c, --bytes=[+]NUM
output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file

You could probably do something with dd too by setting bs=1 and skiping to the offset you want to start e.g.

dd if=file bs=1024k skip=12g | grep something