Bitpath

Lesson 2 · Unit 01

Make, move, remove

mkdir, cp, mv, rm, and how the shell expands * before a command runs

13 exercisesabout 3 min

What you practise

  • mkdir -p, touch, cp -r, mv, rm -r, globs (*, ?, []) expand before the command runs, quoting names with spaces, why rm has no undo

Try a question from this lesson

Pick one

The folder is empty: there is no a yet. What does ls print after this?

shell
mkdir a/b/c
ls

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Copy, move, delete

cp copies, mv moves, rm deletes. Renaming is just moving to a new name.

Folders need -r (recursive) for cp and rm, because the command has to walk everything inside.

rm does not use a trash. What it deletes is gone.

shell
cp a.txt b.txt     # copy a file
cp -r src backup   # copy a folder
mv b.txt c.txt     # rename
rm c.txt           # delete a file
rm -r backup       # delete a folder

Concept

Globs

A glob is a pattern the shell swaps for matching file names before the command runs. The command never sees the pattern.

* matches any run of characters, ? exactly one character, and [ab] one character from the set.

If nothing matches, the pattern is passed along unchanged.

shell
ls *.txt        # ends in .txt
ls photo?.jpg   # photo1, not photo10
ls [ab]*.log    # starts with a or b

10 more exercises in the app

  • 2× fill the blanks
  • 3× type the answer
  • 1× true or false
  • 3× multiple choice
  • 1× order the lines

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy