我创建了一个命名文件描述符{out}:
- $exec {out}>out
但是当我尝试写入命名文件描述符时,会使用文件描述符的名称创建一个新文件:
- $echo >&{out}
- $find . -name {out}
- ./{out}
Bash manual说:
Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {varname}.
如果我用数字代替它,它可以正常工作:
- $exec 3>out
- $echo test >&3
- $cat out
- test
如何使用命名文件描述符?