不会$!在Shell脚本中有意义 [英] Does $! mean something in shell scripting
本文介绍了不会$!在Shell脚本中有意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
bash/shell脚本中是否存在 $!,如果是,请告知其用途.为什么在命令行上运行echo $!
时,它会显示空白?
Does $! exists in bash/shell script, if yes, please inform for what it is used for. And why it gives blank when echo $!
is run on the command line?
推荐答案
除了其他答案外,此回声
In addition to other answer, this echo
echo $!
如果您尚未在当前Shell中在后台运行任何进程,则将打印空白.如果您现在运行:
Will print blank if you haven't yet run any process in background in current shell. If you now run:
date &
echo $!
然后它将打印类似的内容(即上次执行的后台进程的进程ID):
Then it will print something like (i.e. process id of last executed background process):
47833
这篇关于不会$!在Shell脚本中有意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文