Linux Essentials showed variables at the prompt. In a script, name the values it uses at the top, where they're easy to change:
text
learner@reef:~$ cat bake.sh
#!/bin/bash
item="lemon cake" ← no spaces around =
mkdir -p ~/menu/"$item" ← "$item" in double quotes
echo "Baking the $item"
learner@reef:~$ ./bake.sh
Baking the lemon cake| Write | Because |
|---|---|
item="lemon cake" | With spaces around =, bash runs item as a command |
"$item" | Without quotes, lemon cake is two arguments: two folders |
~/menu/"$item" | Inside quotes, ~ is a plain character, not your home |
Ana's script ~/open.sh makes a folder for the shop and says that it is open. It is broken:
- Read the error. Fix the script with
nano ~/open.sh, so that./open.shopens thenorthshop with no error. - Change it to open the
east sideshop, in one folder:~/shops/east side.
Objectives
- Fix the script, so that
./open.shopens thenorthshop without errors. - Change it to open the
east sideshop: one folder,~/shops/east side.