ch02 · beginner · 90-120 min

files, text, and safe changes

Create, copy, move, remove, read, and search files with preview-first discipline.

You can change files in a disposable workspace and explain the safety check before each change.

filesdirectoriestextgreprm safety
Teaching diagramch02 · mental model
Preview-first discipline: prove the target before you change it locate pwd preview ls / printf / stat act cp -i / mv / rm -i verify ls/stat shell expands the glob FIRST *.bak -> file1 file2 file3 rm only ever sees the final names read before you dump less / head -n / tail -f for bounded reads grep -rn gives file:line evidence never act from an unverified directory or an unpreviewed glob

shows: The repeated locate -> preview -> act -> verify loop behind every file change, plus the fact that the shell expands globs before the command ever runs and that bounded readers precede searching.

does not prove: The loop is a discipline, not a guarantee: a clean preview proves the target you saw, not that another process won't change the directory between preview and act, nor that flags like -a copied the right metadata.

Lessons in this chapter

  1. ch02/l01 Create and copy without losing metadata mkdir -p Build test spaces, copy intentionally, and preserve metadata when it matters.
  2. ch02/l02 Move and remove after preview rm -i Treat deletion as a workflow, not a single command.
  3. ch02/l03 Read and search text under pressure grep -rn Use the right read/search tool for file size, context, and evidence.
capstone

safe file-change exercise

Create a disposable app directory, back up config, move one file, remove only previewed targets, and find one error in copied logs.

Deliverable

A transcript with every preview and verification command.

Success criteria

  • No command targets a production path.
  • Every destructive step is preceded by a proof step.
  • Search output includes file and line evidence.
Terminal Drill companion

Files & Directories

After your lab transcript shows preview-before-change discipline.

Train after the lesson