linux - 这个 shell 命令是什么意思 "exec 3>&1 >>(logger -t "OKOK")"

标签 linux bash

我在一些源代码中发现了以下 bash 命令。

exec 3>&1 > >(logger -t "OKOK")

具体是什么意思?

据我所知,它将这些日志重定向到系统日志。

但是,3>&1 是什么?

我以前从未见过3的文件描述符。

最佳答案

确实不寻常,但确实存在:

Each open file gets assigned a file descriptor. The file descriptors for stdin, stdout, and stderr are 0, 1, and 2, respectively. For opening additional files, there remain descriptors 3 to 9. It is sometimes useful to assign one of these additional file descriptors to stdin, stdout, or stderr as a temporary duplicate link. This simplifies restoration to normal after complex redirection and reshuffling

IO redirection page 上了解更多信息.

关于linux - 这个 shell 命令是什么意思 "exec 3>&1 >>(logger -t "OKOK")",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12194616/

相关文章:

linux - 将 DMA 缓冲区写入内存映射文件

windows - Linux/Unix中 "Performance Counters"的概念

linux - 无法获得对 dbus-send 的任何回复

linux - Artisan 上的 Laravel 'sudo: no tty' 错误::从清漆清除缓存时调用

bash - 如何使用文件名重命名多个多fasta文件中的 header ?

python - 从python访问没有-fPIC编译的库

sql - 阻止 BigQuery 截断输出

linux - Bash - 获取端口 ID 的脚本

linux - 通过自己的脚本临时更改 bash 提示符

html - Bash 脚本将类附加到 html 文件