1<filename have any meaning?Perhaps it means "keyboard -> stdout"?
We really shouldn't open an input file on stdout. (You need
exec before that redirection for it to work. But it will probably still fail and block) If you want to open a file with an fd just use 3 or something.
exec 3<filename # do something with fd 3 exec 3<&-
It is possible to redirect to fd 0 (stdin), but if you exec fd 0 to point somewhere else, then you should save it first.
exec 3<&0 exec < filename # do something with the file on fd 0 # restore stdin, free fd3 exec 0<&3 3<&-
1<filename is a redirection, it tells the shell to open the file
filename for reading, and make it available on file descriptor 1 for the command being run (or for the whole shell process, if you use the redirection with
exec). This is as it usually works for all redirections:
< marks an input redirection, and the optional number at the front specifies a file descriptor number.
What's unusual about that redirection is that fd 1 is reserved for the standard output stream, so programs generally assume it can be written to. If it's opened by an input redirection, this assumption will fail.
$ touch filename $ ls 1<filename ls: write error: Bad file descriptor
The same would happen if you'd open fd 2 (stderr) for input, or fd 0 (stdin) for output.
$ cat 0> filename cat: -: Bad file descriptor
Of course, if stderr can't be written to, you won't get an error message. You will, probably get a falsy nonzero exit status.