linux - "rc=$$? ; cat File1 >/proc/self/fd/2 ; exit $$rc"命令在 Linux shell 中做什么?

标签 linux bash

请帮我完整理解以下命令:

python3 code.py >result.txt 2>&1 || ( rc=$$? ; cat result.txt >/proc/self/fd/2 ; exit $$rc )

在上面的代码中,我找不到什么rc=$$?$$rc意思是。

最佳答案

在 Bash 中,$$ 是进程 ID,? 用于查找最后执行的命令的返回值。所以基本上这会获取进程 ID 并为其分配一个变量 rc。然后看起来退出,代码等于进程 ID。

关于linux - "rc=$$? ; cat File1 >/proc/self/fd/2 ; exit $$rc"命令在 Linux shell 中做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60035208/

相关文章:

c++ - Xlib 测试窗口名称

java - Bash - 通过搜索整个系统来查找 java 类及其 jar 目录

ruby - 如何将cookbook_file与bash结合使用?

bash - 如何在 dockerfile 中重新加载 .bashrc

bash - 如何从命令行进行递归查找和替换?

linux - 动态 "magit"Git 可执行文件取决于 Emacs lisp 中的环境

linux - Bash - for循环中的多个条件

c++ - 套接字和线程

python - 如何终止使用 Subprocess.Popen 启动进程的函数并移至下一行代码?

Bash:uniq计数大数据集