$
Lernen Linux-Handbuch
de
XP:0
Quest 22Expansionist
+220 XP

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

Interaktives Terminal für diese Quest starten→Keine Installation erforderlich • Läuft im Browser

Konzept & Übersicht

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.

Befehlssyntax-Referenz

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

Prüfungsziele

  • ○
    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

Bereit für Quest 22?