Interview Prep/Real-World Interview/awk, sed, grep and jq one-liners

Print only the lines containing "ERROR" with 3 lines of context, and show line numbers.

BeginnerHands-onawk, sed, grep and jq one-liners
Answer
grep -n -C 3 'ERROR' app.log

Key trick → -C gives context both ways (-A after, -B before) and -n adds line numbers so you can jump to the spot in less +<n>.

All Real-World Interview questions Roadmap: Interview readiness

More on awk, sed, grep and jq one-liners