nerdexam
CompTIA

LX0-103 · Question #156

Which of the following command line redirection characters instructs the shell to read from the current input source until a specific word, on a separate line and without and trailing spaces, is reach

The correct answer is A. <<. The << operator introduces a here-document, instructing the shell to read lines from the current input until a user-defined delimiter word appears alone on a line. The other options are not valid shell redirection operators.

GNU and Unix Commands

Question

Which of the following command line redirection characters instructs the shell to read from the current input source until a specific word, on a separate line and without and trailing spaces, is reached?

Options

  • A<<
  • B<|
  • C!<
  • D&<<

How the community answered

(25 responses)
  • A
    92% (23)
  • B
    4% (1)
  • D
    4% (1)

Why each option

The << operator introduces a here-document, instructing the shell to read lines from the current input until a user-defined delimiter word appears alone on a line. The other options are not valid shell redirection operators.

A<<Correct

The here-document operator << is followed by a delimiter token (e.g., EOF), and the shell feeds all subsequent lines as stdin to the command until it encounters that exact token on a line by itself with no leading or trailing spaces. This is a standard POSIX shell feature used to embed multi-line input directly in scripts without requiring a separate file.

B<|

<| is not a defined shell redirection operator in any POSIX or Bash specification.

C!<

!< is not a valid shell redirection character combination; ! is used for history expansion or negation in conditional contexts, not input redirection.

D&<<

&<< is not a valid shell redirection operator; & is used with file descriptors for output duplication (e.g., 2>&1) but has no meaning combined with << in this way.

Concept tested: Here-document shell redirection operator

Source: https://www.gnu.org/software/bash/manual/bash.html#Here-Documents

Topics

#shell scripting#here documents#input redirection#command line

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice