什么`$$`代表ps命令?

时间:2012-05-22 13:44:29

标签: linux

  

可能重复:
  What does $$ mean in the shell?

$ ./cruncher & ./cruncher & ./cruncher &
$ ps -C cruncher -p $$ -o pid,state,cmd
PID S CMD
2588 S bash
2657 R /bin/sh ./cruncher
2658 R /bin/sh ./cruncher
2659 R /bin/sh ./cruncher

-C cmdlist      Select by command name.
                       This selects the processes whose executable name is
                       given in cmdlist.

-p pidlist      Select by PID.
                       This selects the processes whose process ID numbers
                       appear in pidlist.

问题> $$是什么意思?

2 个答案:

答案 0 :(得分:3)

它与ps命令无关,$$由shell替换为其进程ID

答案 1 :(得分:1)

它是一个内置的shell变量,它包含PID进程ID。