New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
The log file you need to search through is bigger than the memory your script is allowed to use.
What you'll have at the end
A script that finds every line matching a pattern in a multi-gigabyte log file and writes them out, using a peak memory footprint well under a tenth of the file's own size.
You need
A log file already sitting on disk, too large to comfortably read into memory in one go, and a plain string or short pattern you need to find every occurrence of.
Not covered
Watching a log file for new lines as it keeps growing, which needs different logic from searching one that has already finished growing.
Leans on
Checked 25 Aug 2026
Part of the Node.js cookbook