Menu
Coddy logo textTech

Recap - Selective Operations

Part of the Fundamentals section of Coddy's Terminal journey. Lesson 29 of 82.

challenge icon

Challenge

Easy

Put all your wildcard skills together!

  1. Create a new directory called archive using mkdir
  2. Move only the single-digit .jpg photo files into archive/ using the [0-9] bracket wildcard
  3. Move all report_?.txt files into archive/ using the ? wildcard
  4. Delete all remaining .png files using the * wildcard
  5. List the home directory with ls to confirm what remains
  6. List the archive folder with ls archive to confirm its contents

Note: photo_10.jpg should stay in the home directory. It has two digits so it won't be matched by [0-9]. Think carefully about which wildcard to use for each step!

The listing here sorts photo_10.jpg before photo_1.jpg: ls uses the sandbox locale, which ignores the underscore when comparing names. On your own machine the order may differ. Compare the set of files, not the order. The check looks at the final state of your files after all your commands, so it does not matter whether you list them in one command or two, or how many times you looked around on the way.

⚠ Clean up first: If you see unexpected directories (like family, nature, or travel) in your home directory, possibly left over from a previous lesson, remove them before running the steps above. Use rm -rf <dirname> for each one (for example, rm -rf family). This ensures your ls output matches the expected result.

Try it yourself

Terminal

All lessons in Fundamentals

Practice on your own: Terminal playground