LX0-103 · Question #52
Which of the following are valid stream redirection operators within Bash? (Choose THREE correct answers.)
The correct answer is A. < B. <<< C. >. Bash recognizes < for input redirection, <<< for here-strings, and > for output redirection; the other options are not valid Bash operators.
Question
Which of the following are valid stream redirection operators within Bash? (Choose THREE correct answers.)
Options
- A<
- B<<<
- C
- D
- E%>
How the community answered
(48 responses)- A96% (46)
- D2% (1)
- E2% (1)
Why each option
Bash recognizes < for input redirection, <<< for here-strings, and > for output redirection; the other options are not valid Bash operators.
< is the standard input redirection operator that feeds a file's contents into a command's stdin. <<< is the here-string operator that passes a literal string directly to a command's stdin without requiring a file or subshell. > is the standard output redirection operator that writes stdout to a file, truncating any existing content. All three are explicitly defined redirection operators in the Bash reference manual.
<<< is the here-string operator that passes a literal string directly to a command's stdin without requiring a file or subshell.
> is the standard output redirection operator that writes stdout to a file, truncating any existing content.
>>> is not a valid Bash operator; >> is the valid append-output operator, but adding a third > is a syntax error in Bash.
%> is not a Bash operator; it appears in languages like Perl or in PowerShell, but carries no meaning as a stream redirector in Bash.
Concept tested: Bash stream redirection operators including here-string
Source: https://www.gnu.org/software/bash/manual/bash.html#Redirections
Topics
Community Discussion
No community discussion yet for this question.