What is the meaning for $! in shell or shell scripting? I am trying to understand a script which has the something like the following.
local@usr> a=1
local@usr> echo $a
1
local@usr> echo $!a
a
It is printing the variable back. Is it all for that? What are the other $x options we have? Few I know are $$, $*, $?. If anyone can point me to a good source, it will be helpful. BTW, This is in Sun OS 5.8, KSH.
The various $…
variables are described in Bash manual. According to the manual $!
expands to the PID of the last process launched in background. See:
$ echo "Foo"
Foo
$ echo $!
$ true&
[1] 67064
$ echo $!
67064
[1]+ Done true
In ksh
it seems to do the same.
From the ksh
man page on my system:
${!vname} Expands to the name of the variable referred to by vname. This will be vname except when vname is a name reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With