World map

 

BM: Baca dalam Bahasa Melayu

World L4: Remote Kitchens

Bash scripts: variables and if

You will learn: to read and run a small script with variables, arguments and if.

Checked with Linux (Debian 13) on 1 Nov 2026

The problem

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

You are hereyou@kedai:~$

Folder ~

  • open.sh (file)-rwxr-xr-xcan run

+ 3 hidden (ls -a)

Services

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

The opening checklist refuses to start. It wants something from you. What?

Watch

A script: A written checklist for the shell. It runs the lines one by one. is a written checklist for the shell. Here is open.sh. Tap the line that reads what you type after ./open.sh.

Tap the line that reads your word.

0 of 1 found

Try it

A variable is a labelled jar. name=Aina fills it (no spaces around =). $name reads it. Try it.

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

You are hereyou@kedai:~$

Folder ~

  • open.sh (file)-rwxr-xr-xcan run

+ 3 hidden (ls -a)

Services

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

Predict

name=Aina, then echo 'Hi $name' with single quotes. What prints?

Pick one answer.

Watch

if [ -z "$worker" ] asks a yes/no question. -z means “is it empty?”. Sort the questions.

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

      Try it

      Run the checklist with a name. Then make menu.txt and run it again. Watch the if change its answer.

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

      You are hereyou@kedai:~$

      Folder ~

      • open.sh (file)-rwxr-xr-xcan run

      + 3 hidden (ls -a)

      Services

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

      Check

      Good line or needs work?

      Swipe right for good, left for needs work. Or use the buttons.

      1 / 4name=Aina
      name=Aina

      You did it!

      You can now read a script’s variables and ifs, and run it with a word.

      Go deeper (optional)

      Always quote jars: "$worker". Then a name with spaces stays one word. $(date +%F) fills a jar with a command’s output. shellcheck reads scripts and points at mistakes (sudo apt install shellcheck).

      Real mission

      1. chmod +x hi.sh
      2. ./hi.sh Aina

      0 of 3 steps done · Your ticks are saved.