Reputation: 41
I am playing with file descriptors. A common practice is to redirect stdout and stderr using file descriptors, like this:
$ ls >files.txt 2>errors.txt
another example might be:
$ echo 'Hello there' > message.txt 2> errors.txt
however the following does not work:
$ echo 'Hello There' 0> input_message.txt > output_message.txt 2> errors.txt
It seems like the file descriptor 0 is not working as input_message.txt
is empty, I'd expect to find the text message Hello There
instead.
Why is that ?
Upvotes: 0
Views: 182
Reputation: 50815
You use <
(or 0<
) to redirect stdin, like:
command <file
or:
command <&fd
where fd
is a file descriptor opened for reading.
As for your example, since echo
ignores stdin, this correction won't change the behavior.
See Bash Reference Manual § 3.6 Redirections.
Upvotes: 2