Which of the following commands redirects the output of ls to standard error?
Which of the following commands redirects the output of ls to standard error?
To redirect the output of the 'ls' command to standard error (stderr), you use the file descriptor '2'. The 'ls >&2' command accomplishes this by redirecting the standard output (stdout) of 'ls' to standard error. Other options either do not use the correct redirection symbol or attempt to use invalid or incorrect syntax. For example, 'ls >-1' creates a file named '-1', 'ls <<err' is syntactically incorrect, 'ls >>2' appends to a file named '2', and 'ls |error' attempts to pipe the output to a non-existent 'error' command.
@okamigo, E is absolutely false because it isn't even using the re-directional symbol (>). The correct answer is C. D is wrong because the append symbol (>>) cannot append to STDERR(2). It needs a file to append the out of 'ls' to.
C it's not correct answer I think E it wright answer
nope, E ls |error, this command redirect output of ls command to error command which is not found. answer C is correct
C is correct: ls>&2 sends the ls output to the 2 (stderr) location A, B, D, and E are wrong: ls>-1 creates a file -1 that is the output of ls <<ERR sets the ERR string as the end of input ls>>2 would append to a file '2' ls |error is an invalid command
Answer: C