$
Apprendre Manuel Linux
fr
XP :0
Quête 22Expansionist
+220 XP

Brace Expansion & Safe Directory Removal ({} & rmdir)

Lancer le terminal interactif pour cette quête→Aucune installation requise • S'exécute dans le navigateur

Concept et aperçu

Bash brace expansion {} is a powerful productivity feature that generates arbitrary string combinations before commands run, eliminating repetitive typing:

- Comma-separated lists: mkdir -p app/{src,bin,logs} expands to app/src, app/bin, and app/logs in a single command.
- Numeric or alphabetic ranges: touch file_{1..3}.txt expands to file_1.txt, file_2.txt, and file_3.txt.

When deleting folders, rm -r deletes everything recursively without safety checks. By contrast, rmdir provides a strict safety guarantee: it only removes directories that are completely empty, preventing accidental loss of files.

Practice brace expansion and safe directory removal!
1. Run mkdir -p app/{src,bin,logs} to build multiple application directories at once.
2. Run touch file_{1..3}.txt to create three numbered files in one command.
3. Safely delete the empty folder temp_empty using rmdir temp_empty.

Référence de syntaxe des commandes

Command / SyntaxDescription
mkdir -p app/{src,bin,logs}Create multiple directories using brace expansion
touch file_{1..3}.txtCreate sequential files using range expansion
rmdir temp_emptySafely remove an empty directory

Objectifs de vérification

  • ○
    Create directories app/src, app/bin, and app/logs using brace expansion
  • ○
    Create file_1.txt, file_2.txt, and file_3.txt using brace expansion
  • ○
    Safely remove directory temp_empty using rmdir

Prêt à terminer la Quête 22?