Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does $! mean something in shell scripting

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?

like image 500
pRAShANT Avatar asked Aug 27 '13 10:08

pRAShANT


1 Answers

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
like image 189
anubhava Avatar answered Sep 21 '22 18:09

anubhava