NCAE Mapping Hub
Overview Scoreboard Data Roles Exercised Checklists Lessons Skill Drills Practice Terminal Progress
performance medium Apply pipeline-distinct 2 points

Question 38. CSCD240-E1-A

Count distinct lines in visitors.txt (unsorted input).

Work the drill

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

Ideal answer
sort visitors.txt | uniq | wc -l
Acceptable alternatives: ["sort -u visitors.txt | wc -l", "cat visitors.txt | sort -u | wc -l"]

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.

uniq visitors.txt | wc -l
Misconception. uniq without sort collapses only adjacent duplicates.
Remedy. Golden rule: always sort BEFORE uniq.
wc -l visitors.txt
Misconception. Counts ALL lines, not distinct.
Remedy. Read the question: distinct vs total.

Authority mappings

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

DCWF tasks: T0259
KU outcomes: CD-BSP-O1CO-M9-O1
NCAE errors: SSH Login / failure: Failed to connect to host: IPSSH Login / partial: The following users failed t.SSH Login / partial: The following users failed t.

Course-artifact links

Lectures

  • CSCD240-S26-L08. Pipes, filters, grep, sort, uniq, wc, tar

Lab questions

  • CSCD240-S26-LAB4: Build pipeline: sort words.txt | uniq -c | sort -rn | head. Top-N frequency.