Difficulty: Easy
Correct Answer: None of the above
Explanation:
Introduction / Context:
Unix excels at building pipelines by connecting programs that read from standard input and write to standard output—these are commonly called filters. Recognizing which commands behave as filters helps you compose effective pipelines for searching, counting, sorting, and transforming text.
Given Data / Assumptions:
Concept / Approach:
sort sorts lines received from stdin or files and writes sorted output to stdout. wc counts lines, words, and bytes from stdin or files and prints results to stdout. grep filters lines matching a pattern, again from stdin or files, to stdout. cat concatenates files or stdin and writes to stdout, often used as a simple pass-through or to combine streams. All four therefore qualify as filters when used in pipelines.
Step-by-Step Solution:
Verification / Alternative check:
Run a simple pipeline: printf "b\na\nc\n" | sort | wc -l. Insert cat anywhere in the chain; it still reads stdin and writes stdout, proving its filter behavior in practice.
Why Other Options Are Wrong:
Common Pitfalls:
Thinking “cat” is not a filter because it often reads files by name; in fact, it reads stdin when no file is specified, making it a filter. Likewise, all of the listed commands can take input from stdin, aligning with the filter definition.
Final Answer:
None of the above
Discussion & Comments