Searching for a keyword is like looking through a keyhole. You see the object, but you don’t see the room it’s in. In the Linux terminal, we use Context Flags to open the door.

The Three Rituals of Vision

  1. The Retrospect (-B): grep -B 3 "Total" ledger.journal This shows the ‘Total’ line and the 3 lines before it—perfect for seeing which items led to a specific sum.

  2. The Prospect (-A): grep -A 5 "func main" main.go This shows the start of your Go program and the next 5 lines of code.

  3. The Panorama (-C): grep -C 2 "CRITICAL" system.log This creates a ‘sandwich’ of 2 lines above and 2 lines below your error, giving you the full picture of the crash.

The Separator

When you search through multiple matches with context, Grep automatically inserts a -- separator between the ’neighborhoods.’ This keeps the forge organized and prevents the data from bleeding together.


Forged in the terminal. Refined under the anvil.