Peng Yu
2017-01-19 21:51:50 UTC
Hi, I don't quite understand who unamed pipe is done in bash. It seems
unnamed pipe is mapped to a fd in /dev/fd/<id>. 63 is always used as
the first one. Why the 2nd command won't run correctly?
$ cat <(echo xxx)
xxx
$ cat $(echo <(echo xxx))
cat: /dev/fd/63: Bad file descriptor
$ echo <(echo xxx)
/dev/fd/63
$ echo <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx)
/dev/fd/63 /dev/fd/62 /dev/fd/61 /dev/fd/60 /dev/fd/59 /dev/fd/58
/dev/fd/57 /dev/fd/56 /dev/fd/55 /dev/fd/54 /dev/fd/53 /dev/fd/52
/dev/fd/51 /dev/fd/50 /dev/fd/49 /dev/fd/48 /dev/fd/47 /dev/fd/46
/dev/fd/45 /dev/fd/44 /dev/fd/43 /dev/fd/42 /dev/fd/41 /dev/fd/40
/dev/fd/39 /dev/fd/38 /dev/fd/37 /dev/fd/36 /dev/fd/35 /dev/fd/34
/dev/fd/33 /dev/fd/32 /dev/fd/31 /dev/fd/30 /dev/fd/29 /dev/fd/28
/dev/fd/27 /dev/fd/26 /dev/fd/25 /dev/fd/24 /dev/fd/23 /dev/fd/22
/dev/fd/21 /dev/fd/20 /dev/fd/19 /dev/fd/18 /dev/fd/17 /dev/fd/16
/dev/fd/15 /dev/fd/14 /dev/fd/13 /dev/fd/12 /dev/fd/11 /dev/fd/10
/dev/fd/9 /dev/fd/8 /dev/fd/7 /dev/fd/6 /dev/fd/5 /dev/fd/3 /dev/fd/4
/dev/fd/64 /dev/fd/65 /dev/fd/66 /dev/fd/67 /dev/fd/68 /dev/fd/69
/dev/fd/70 /dev/fd/71 /dev/fd/72 /dev/fd/73 /dev/fd/74 /dev/fd/75
/dev/fd/76 /dev/fd/77 /dev/fd/78 /dev/fd/79 /dev/fd/80 /dev/fd/81
/dev/fd/82 /dev/fd/83 /dev/fd/84 /dev/fd/85 /dev/fd/86 /dev/fd/87
/dev/fd/88 /dev/fd/89 /dev/fd/90
unnamed pipe is mapped to a fd in /dev/fd/<id>. 63 is always used as
the first one. Why the 2nd command won't run correctly?
$ cat <(echo xxx)
xxx
$ cat $(echo <(echo xxx))
cat: /dev/fd/63: Bad file descriptor
$ echo <(echo xxx)
/dev/fd/63
$ echo <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx)
<(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo xxx) <(echo
xxx)
/dev/fd/63 /dev/fd/62 /dev/fd/61 /dev/fd/60 /dev/fd/59 /dev/fd/58
/dev/fd/57 /dev/fd/56 /dev/fd/55 /dev/fd/54 /dev/fd/53 /dev/fd/52
/dev/fd/51 /dev/fd/50 /dev/fd/49 /dev/fd/48 /dev/fd/47 /dev/fd/46
/dev/fd/45 /dev/fd/44 /dev/fd/43 /dev/fd/42 /dev/fd/41 /dev/fd/40
/dev/fd/39 /dev/fd/38 /dev/fd/37 /dev/fd/36 /dev/fd/35 /dev/fd/34
/dev/fd/33 /dev/fd/32 /dev/fd/31 /dev/fd/30 /dev/fd/29 /dev/fd/28
/dev/fd/27 /dev/fd/26 /dev/fd/25 /dev/fd/24 /dev/fd/23 /dev/fd/22
/dev/fd/21 /dev/fd/20 /dev/fd/19 /dev/fd/18 /dev/fd/17 /dev/fd/16
/dev/fd/15 /dev/fd/14 /dev/fd/13 /dev/fd/12 /dev/fd/11 /dev/fd/10
/dev/fd/9 /dev/fd/8 /dev/fd/7 /dev/fd/6 /dev/fd/5 /dev/fd/3 /dev/fd/4
/dev/fd/64 /dev/fd/65 /dev/fd/66 /dev/fd/67 /dev/fd/68 /dev/fd/69
/dev/fd/70 /dev/fd/71 /dev/fd/72 /dev/fd/73 /dev/fd/74 /dev/fd/75
/dev/fd/76 /dev/fd/77 /dev/fd/78 /dev/fd/79 /dev/fd/80 /dev/fd/81
/dev/fd/82 /dev/fd/83 /dev/fd/84 /dev/fd/85 /dev/fd/86 /dev/fd/87
/dev/fd/88 /dev/fd/89 /dev/fd/90
--
Regards,
Peng
Regards,
Peng