World map

 

BM: Baca dalam Bahasa Melayu

World L1: The Shophouse

Search inside files: grep

You will learn: to pull out only the lines you need from a long file.

Checked with Linux (Debian 13) on 1 Nov 2026

The problem

The boss asks: which tables have not paid? The order book has 15 lines today. Tomorrow it may have 900.

Pick one answer.

Watch

You are you in /home/you/kedai/counter. 1 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~/kedai/counter$

Folder ~/kedai/counter

  • orders.log (file)-rw-r--r--

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

grep prints only the lines that contain your word. Two tables have not paid: T5 and T6. Or is that all?

Predict

One cashier wrote Unpaid, not UNPAID. Did grep show that line?

Pick one answer.

Try it

Catch every spelling: grep -i unpaid orders.log.

You are you in /home/you/kedai/counter. 1 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~/kedai/counter$

Folder ~/kedai/counter

  • orders.log (file)-rw-r--r--

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

Check

Tap every line that grep T6 orders.log prints.

0 of 2 found

Check

Three handy switches. Which one answers each question?

Drag a card into a box. Or tap the card, then tap the box.

        Try it

        How many nasi lemak orders today? Ask grep to count: grep -c nasi-lemak orders.log.

        You are you in /home/you/kedai/counter. 1 things here. Services: cron running, ssh running, nginx running.

        You are hereyou@kedai:~/kedai/counter$

        Folder ~/kedai/counter

        • orders.log (file)-rw-r--r--

        Services

        • cronrunningstarts at boot
        • sshrunningstarts at boot
        • nginxrunningstarts at boot

        You did it!

        You can now pull just the lines you need from a file.

        Go deeper (optional)

        grep laksa orders.log prints nothing and ends with exit code 1. Plain words: no line matched; nothing broke. grep -r belacan ~/kedai searches every file in every room. grep -n and -i mix: grep -ni unpaid orders.log.

        Real rep (optional): on Linux, grep -c bash /etc/passwd counts users with bash as their shell.