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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In addition to other answer, this echo
echo $!
Will print blank if you haven't yet run any process in background in current shell. If you now run:
date &
echo $!
Then it will print something like (i.e. process id of last executed background process):
47833
回答2:
$!
is the PID of the last program your shell ran in the background
回答3:
$! - shows last process ID which has started in background.