LFCS · Question #831
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…
The correct answer is A. <<. The << characters are used in Bash to create a 'here document' (heredoc), which allows multiline input to be supplied to a command until a specified separator string is encountered on its own line.
Question
Options
- A<<
- B<|
- C!<
- D&<
How the community answered
(30 responses)- A93% (28)
- B3% (1)
- C3% (1)
Why each option
The `<<` characters are used in Bash to create a 'here document' (heredoc), which allows multiline input to be supplied to a command until a specified separator string is encountered on its own line.
The `<<` shell operator signifies a 'here document' or 'heredoc', which reads input from the current source until a line containing only the specified separator string (often called a 'delimiter' or 'terminator') is found. This is commonly used to provide multiline input to commands or scripts.
`<|` is not a standard shell redirection or special character combination for input in this context.
`!<` is not a standard shell redirection or special character combination for input in this context; `!` is typically used for history expansion or negation.
`&<` is not a standard shell redirection or special character combination for input in this context; `&` is used for backgrounding commands or combining file descriptors.
Concept tested: Bash here document syntax
Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Here-Documents
Topics
Community Discussion
No community discussion yet for this question.