nerdexam
CompTIA

LX0-103 · Question #18

Which of the following characters can be combined with a separator string in order to read from the current input source until the separator string, which is on a separate line and without any trailin

The correct answer is A. <<. The << operator introduces a here-document (heredoc) in shell scripting, reading input until a specified delimiter string appears alone on a line.

GNU and Unix Commands

Question

Which of the following characters can be combined with a separator string in order to read from the current input source until the separator string, which is on a separate line and without any trailing spaces, is reached?

Options

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

How the community answered

(36 responses)
  • A
    89% (32)
  • B
    3% (1)
  • C
    6% (2)
  • D
    3% (1)

Why each option

The << operator introduces a here-document (heredoc) in shell scripting, reading input until a specified delimiter string appears alone on a line.

A<<Correct

The << operator begins a heredoc block, which redirects input from the shell script itself rather than a file. The shell reads lines until it encounters the delimiter string on a line by itself with no leading or trailing whitespace. For example, 'cat << EOF' collects all lines until a line containing only 'EOF' is reached.

B<|

<| is not a valid shell operator for any input redirection or heredoc purpose.

C!<

!< is not a valid shell operator - the ! character in shell is used for history expansion, not input redirection.

D&<

&< is not a valid shell operator for reading until a separator string.

Concept tested: Shell heredoc syntax and input redirection

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

Topics

#heredoc#here document#input redirection#bash

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice