Learn Understand first, then practice while the concept is still fresh.

M56 - CLI Intensive 3: One-Line Power

Use concise one-line commands for safe operational work while preserving dry-run habits, verification, and reversibility.

CLI Intensive & Capstone

CLI Intensive 3: One-Line Power

Use concise one-line commands for safe operational work while preserving dry-run habits, verification, and reversibility.

35 min ADVANCED BOTH Curriculum-reviewed
What you should be able to do after this
  • Use concise one-line commands for safe operational work while preserving dry-run habits, verification, and reversibility.

One-Liners Are Best When They Stay Understandable

A one-liner is useful because it lets you solve a focused task quickly.

It becomes dangerous when:

  • you cannot explain the target set
  • you skip the verification step
  • the final action is destructive and untested

The goal here is not to collect clever commands. It is to learn short, trustworthy workflows.


Drill A: Inspect Before You Act

Objective: Find a specific process family and review the matching set before deciding on any follow-up action.

Inspect matching processes

Get-Process chrome | Sort-Object WorkingSet -Descending

Inspect matching processes

ps aux | grep “[c]hrome”

This drill is intentionally incomplete. The point is to practice the inspection step before you ever append a stop or kill action.


Drill B: Rename Many Files Safely

Objective: Rename a batch of files by replacing spaces with underscores.

Create a few sample files first, then rename them in one concise command pattern.

One possible Windows solution

Get-ChildItem -Filter *.txt | Rename-Item -NewName { $.Name -replace ’ ’,'' }

One possible Linux solution

for f in *.txt; do mv “$f” “${{f// /_}”; done

This is a good example of one-line power that is useful and easy to verify afterward with a directory listing.


Drill C: Find the Target Set Before Cleanup

Objective: Identify old log files before deciding whether to remove them.

Dry-run log discovery

Get-ChildItem -Path C:\logs -Filter *.log -Recurse | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-30) }

Dry-run log discovery

find /var/log -type f -name “*.log” -mtime +30

Only after you trust that target list should you consider the deletion form of the command.

The Dry-Run Rule

If the final stage deletes, stops, overwrites, or changes permissions, first run the same one-liner without the final action. Review the target list, then add the action only when you are confident it is correct.


Mastery Check

You are ready for the capstone when you can:

  • build concise commands without losing readability
  • verify target sets before adding risky actions
  • explain how the one-liner could be turned into a script if it needed to be reused

The capstone combines these habits with everything else you have learned.