bash “$$”在shell脚本中是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1877302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 21:28:11  来源:igfitidea点击:

What does "$$" means in shell script?

linuxbashshell

提问by vinit dhatrak

I came across "$$" expression in shell script, something like this

我在 shell 脚本中遇到了 "$$" 表达式,类似这样

TFILE=$$

TFILE=$$

Can anyone tell me its meaning?

谁能告诉我它的意思?

回答by Ether

$$means the process ID of the currently-running process.

$$表示当前正在运行的进程的进程 ID。

回答by teapot7

It's the process id of the current process - see a previous question on StackOverflow for details: What does $$ mean in the shell?

它是当前进程的进程 id - 有关详细信息,请参阅 StackOverflow 上的上一个问题:$$ 在 shell 中意味着什么?

回答by Venkataramesh Kommoju

$$ is the process id of the currently running process in UNIX.

$$ 是 UNIX 中当前正在运行的进程的进程 ID。

mostly it is used with naming of logfiles aor temp files, such that there is no conflict of file names while multiple instances of the same scripts are running.

大多数情况下,它与日志文件或临时文件的命名一起使用,以便在运行相同脚本的多个实例时不会出现文件名冲突。

回答by Ashitosh

echo "$$" prints PID of current running process.

echo "$$" 打印当前正在运行的进程的 PID。