shell中特殊变量

 

  1. $#    传递到脚本的参数个数
  2. $$    脚本运行的当前进程PID
  3. $!  最后一个运行的后台进程PID
  4. $-     当前Shell选项
  5. #!/bin/sh
    
    echo "Num of arguments: $#"
    echo "Current PID: $$"
    echo "The last deforegroud PID: $!"
    echo "The current shell options: $-"
    echo "Current PID: $$"                    

     

     

  6. #!/bin/sh
    
    echo "Num of arguments: $#"
    echo "Current PID: $$"
    sleep 10 &
    echo "The last deforegroud PID: $!"
    echo "The current shell options: $-"
    echo "Current PID: $$"                 

     

     

posted @ 2020-09-24 19:34  ascertain  阅读(124)  评论(0编辑  收藏  举报