nerdexam
CompTIA

LX0-103 · Question #52

Which of the following are valid stream redirection operators within Bash? (Choose THREE correct answers.)

The correct answer is A. < B. <<< C. >. Bash recognizes < for input redirection, <<< for here-strings, and > for output redirection; the other options are not valid Bash operators.

GNU and Unix Commands

Question

Which of the following are valid stream redirection operators within Bash? (Choose THREE correct answers.)

Options

  • A<
  • B<<<
  • C
  • D
  • E%>

How the community answered

(48 responses)
  • A
    96% (46)
  • D
    2% (1)
  • E
    2% (1)

Why each option

Bash recognizes < for input redirection, <<< for here-strings, and > for output redirection; the other options are not valid Bash operators.

A<Correct

< is the standard input redirection operator that feeds a file's contents into a command's stdin. <<< is the here-string operator that passes a literal string directly to a command's stdin without requiring a file or subshell. > is the standard output redirection operator that writes stdout to a file, truncating any existing content. All three are explicitly defined redirection operators in the Bash reference manual.

B<<<Correct

<<< is the here-string operator that passes a literal string directly to a command's stdin without requiring a file or subshell.

C>Correct

> is the standard output redirection operator that writes stdout to a file, truncating any existing content.

D>>>

>>> is not a valid Bash operator; >> is the valid append-output operator, but adding a third > is a syntax error in Bash.

E%>

%> is not a Bash operator; it appears in languages like Perl or in PowerShell, but carries no meaning as a stream redirector in Bash.

Concept tested: Bash stream redirection operators including here-string

Source: https://www.gnu.org/software/bash/manual/bash.html#Redirections

Topics

#stream redirection#bash#here-string#I/O operators

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice