>_ IzzyLab

Hands-on task

This task is step 13 of the course “Linux: everyday tasks”

A folder for every month

medium~5 min

The report archive needs a directory for every month of the year: /root/archive/2026-01, /root/archive/2026-02 … /root/archive/2026-12 — exactly 12 of them. Create them with a single command using brace expansion.

What you'll practise:
  • brace expansion
  • {01..12}
  • leading zeros
  • mkdir -p
  • generating names

Topic breakdown

Brace expansion is done by the shell itself: the range {N..M} turns into a sequence of values, and the prefix and suffix around the braces are glued to each one. If the range bounds are written with a leading zero, bash pads all the numbers with zeros to the same width — which gives names that sort correctly. The command receives a ready list of arguments, so no loop is needed. The -p flag of mkdir also creates any missing parent directories.

What's checked

  1. directories 2026-01, 2026-09, 2026-12 created
  2. exactly 12 months in /root/archive and nothing else

What it looks like