Sample Header Ad - 728x90

Bash redirections - handling several filenames specially (man pages)

3 votes
1 answer
160 views
Please confirm/correct me. I've found related https://unix.stackexchange.com/questions/248012/duplication-of-file-descriptors-in-redirection but that does not answer my specific question. From the *The GNU Bash Reference Manual*, section 3.6 Redirections : > Bash handles several filenames specially when they are used in redirections, as described in the following table. If the operating system on which Bash is running provides these special files, bash will use them; otherwise it will emulate them internally with the behavior described below. > > /dev/fd/fd
    If *fd* is a valid integer, file descriptor *fd* is duplicated.
> > /dev/stdin
    File descriptor 0 is duplicated.
> > /dev/stdout
    File descriptor 1 is duplicated.
> > /dev/stderr
    File descriptor 2 is duplicated.
> > A failure to open or create a file causes the redirection to fail. > > Redirections using file descriptors greater than 9 should be used with care, as they may conflict with file descriptors the shell uses internally. What above constitute "special handling" and what "internal emulation behavior"? My guess emulation is done to simulte all aspects of "special handling". Is it correct?
Asked by Martian2020 (1443 rep)
Apr 11, 2025, 03:38 AM
Last activity: Apr 11, 2025, 10:05 AM