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.
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)- A92% (23)
- B4% (1)
- D4% (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.
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.
<| is not a defined shell redirection operator in any POSIX or Bash specification.
!< is not a valid shell redirection character combination; ! is used for history expansion or negation in conditional contexts, not input redirection.
&<< 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
Community Discussion
No community discussion yet for this question.