Sikau

Linux and the shell · Day 5 · about 35 min

Project: Tidy the Downloads folder

Globs, mkdir, mv and rm on a messy folder.

Chaos to order

Your Downloads folder is a mess of photos, PDFs, scripts and temp files. Sort it with a handful of commands — the kind of chore that takes minutes by mouse and seconds in a shell.

Look before you move

It's also the first time you combine several commands into a small plan, which is exactly how shell scripts begin.

Bulk commands are powerful because they act on many files at once, and that's also why they're risky. Before moving or deleting, run ls with the same glob to see exactly which files match. If the list surprises you — a file you wanted to keep, or nothing at all — fix the pattern before running the real command.

cd ~/Downloads
ls *.jpg *.png
mkdir -p images docs scripts
mv *.jpg *.png images/
ls *.tmp
rm *.tmp

The rest of this lesson

  • When a glob matches nothingexplain
  • Why this matters on serversexplain
  • A safe tidy-uporder
  • What matches?match
  • Sort itchallenge
  • Badge quizquiz
  • Unit 1 complete!recap

Continue this lesson free — run real code in your browser

Continue with Google

See all 16 lessons of Linux and the shell