NCAE Mapping Hub
Overview Scoreboard Data Roles Exercised Checklists Lessons Skill Drills Practice Terminal Progress
essay hard Analyze evaluation-order 2 points

Question 40. CSCD240-E1-A

sort data.txt > data.txt — what happens to data.txt and why?

Work the drill

Answer on paper or in a terminal before revealing the ideal answer.

Ideal answer
data.txt becomes empty. The shell evaluates > data.txt FIRST (truncating), then sort reads an empty file and writes nothing back.

Misconception bank

Each row below is a plausible wrong answer, the thinking that produces it, and the remedy that corrects the misconception. These are the foundation of the multiple-choice framing and the targeted feedback a student receives after answering.

File is sorted
Misconception. Expects sort-in-place; missing the clobber rule.
Remedy. Teach shell redirection evaluation order; use sort -o for in-place.
sort errors out
Misconception. Some shells might, but bash does not — it truncates silently.
Remedy. Demo the actual behavior.

Authority mappings

Hover any chip for the mapping justification; click to open the authority record.

DCWF tasks: T0498
KU outcomes: CD-CSP-O4

Course-artifact links

Lectures

  • CSCD240-S26-L07. I/O redirection, aliases, source, .bashrc, env

CTF challenges

  • 03 I/O & Pipelines: where data