UNIX Filters: Identifying Stream-Processing Commands Which of the following is not a filter (i.e., a command commonly used in pipelines to read from standard input and write to standard output)?

Difficulty: Easy

Correct Answer: None of the above

Explanation:


Introduction / Context:
In UNIX, a “filter” is a program designed to read from standard input and write to standard output, making it easy to combine tools using pipelines. Recognizing which commands act as filters helps build effective command-line workflows.


Given Data / Assumptions:

  • We consider classic POSIX utilities available on most UNIX-like systems.
  • A filter participates in pipelines using the | operator.
  • All options listed are common text-processing tools.


Concept / Approach:
Commands like cat, grep, wc, and sort all read from standard input (if no file is provided) and write to standard output. Therefore, each of these is usable as a filter in pipelines, meaning none of the listed commands is “not a filter.”


Step-by-Step Solution:
Test each command with a pipe: e.g., cat file | grep pattern | sort | wc -l.Observe that each command consumes stdin and emits stdout.Conclude that all given commands qualify as filters.


Verification / Alternative check:
Run man pages (e.g., man grep, man sort) to confirm stdin/stdout usage. Try echo "text" | cat, echo "text" | wc, etc., verifying their filter behavior.


Why Other Options Are Wrong:
Options A–D: Each listed command is a valid filter. cat concatenates and passes through data; grep filters by pattern; wc counts lines/words/chars; sort orders lines.


Common Pitfalls:

  • Assuming cat is not a filter because it “only displays”; it still reads stdin and writes stdout.
  • Misusing filters with binary data where text utilities expect text.


Final Answer:
None of the above

More Questions from Unix

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion