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.
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)- A89% (32)
- B3% (1)
- C6% (2)
- D3% (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.
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.
<| is not a valid shell operator for any input redirection or heredoc purpose.
!< is not a valid shell operator - the ! character in shell is used for history expansion, not input redirection.
&< 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
Community Discussion
No community discussion yet for this question.