Which of the following UNIX tools receives input only from standard input?

2019

Which of the following UNIX tools receives input only from standard input?

Answer: D. trConceptA UNIX filter transforms a text or byte stream. Its command syntax shows whether data may come from named input files or must arrive through standard…

  1. A.

    awk

  2. B.

    grep

  3. C.

    sed

  4. D.

    tr

Show answer & explanation

Correct answer: D

Concept

A UNIX filter transforms a text or byte stream. Its command syntax shows whether data may come from named input files or must arrive through standard input.

When a utility has no input-file operand, a pipeline or input redirection supplies the data through standard input.

Application

The syntax of tr uses operands to specify character sets, such as tr set1 set2. Those operands configure the transformation; they are not input filenames. The data stream is therefore read from standard input and the transformed stream is written to standard output.

Contrast

  • awk accepts a program and may also accept input-file operands.

  • grep accepts a pattern and may also accept input-file operands.

  • sed accepts editing commands and may also accept input-file operands.

  • tr accepts character-set operands rather than an input-file operand.

Cross-check

In a pipeline such as printf abc | tr a A, tr receives abc through standard input and produces Abc on standard output. Therefore, the required tool is tr.

Explore the full course: Uppsc Computer Operator Grade B

Loading lesson…