Interview Prep/Linux/Scheduling, automation and scripting

A script must process a 50 GB log file line by line quickly. What tools would you use?

IntermediateScenarioScheduling, automation and scripting
Answer

Situation read → Avoid bash loops for big data; use stream tools.

What I'd do →

LC_ALL=C grep -F ' 500 ' access.log | awk '{print $7}' | sort | uniq -c | sort -rn | head
# split into chunks and process in parallel
split -n l/8 access.log part_ && ls part_* | parallel -j8 "grep -c ERROR {}"

Why → while read in bash is very slow on large files; grep, awk, sort are optimised C. LC_ALL=C skips locale processing for big speedups.

Interview tip → Mention zgrep/zcat for compressed logs instead of unpacking.

All Linux questions Roadmap: Linux

More on Scheduling, automation and scripting