- 论坛徽章:
- 0
|
从教程中拷贝过来,应该足够了, 连方法都出来了.
8.4.2 Process ID Variables and Temporary Files
The only thing new about this is $$ in the filename expression. This is a special shell variable whose
value is the process ID of the current shell.
To see how $$ works, type ps and note the process ID of your shell process (ksh). Then type print "$$";
the shell will respond with that same number. Now type ksh to start a subshell, and when you get a
prompt, repeat the process. You should see a different number, probably slightly higher than the last one.
A related built-in shell variable is ! (i.e., its value is $!), which contains the process ID of the most
recently invoked background job. To see how this works, invoke any job in the background and note the
process ID printed by the shell next to [1]. Then type print "$!"; you should see the same number.
还有个方法:
cat mytest.sh
#!/usr/bin/ksh
while true
do
echo "what's \$\$"
echo $$
sleep 60
done
然后从新开一个终端用ps -ef 去查看这个程序会有比较好的发现,
当然你也可以后台运行上面的程序,它是个死循环程序. |
|