Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法与文件描述符交互而不必在磁盘上打开文件?
如果没有首先将文件分配给 fd3,这将无法工作:
echo a >&3
取决于你想做什么。假设您想在闲暇时编写字符串并将它们反转打印。设置文件描述符重定向到等待标准输入的进程替换:
$ exec 3> >(rev) $ echo hello world >&3 dlrow olleh
完成后,您可以关闭文件描述符
$ exec 3>&- $ echo hello world >&3 bash: 3: Bad file descriptor