zoukankan      html  css  js  c++  java
  • Linux shell 变量$#,$@,$0....的含义

    1 $#:传入的参数数量 
    2 $@:传入的参数列表
    3 $*:传入的参数
    4 $0:Shell本身的文件名
    5 $1,$2...:传入的第 i 个参数
    6 $?:上一条命令返回的状态码
    7 $!:Shell 最后运行的后台 Process 的 PID
    8 $$:Shell本身自己的PID

     实例

     1 #!/bin/bash
     2 #
     3 printf "The complete list is %s
    " "$$"
     4 printf "The complete list is %s
    " "$!"
     5 printf "The complete list is %s
    " "$?"
     6 printf "The complete list is %s
    " "$*"
     7 printf "The complete list is %s
    " "$@"
     8 printf "The complete list is %s
    " "$#"
     9 printf "The complete list is %s
    " "$0"
    10 printf "The complete list is %s
    " "$1"
    11 printf "The complete list is %s
    " "$2

    结果

     1 [Aric@localhost ~]$ bash params.sh 123456 QQ
     2 The complete list is 24249
     3 The complete list is
     4 The complete list is 0
     5 The complete list is 123456 QQ
     6 The complete list is 123456
     7 The complete list is QQ
     8 The complete list is 2
     9 The complete list is params.sh
    10 The complete list is 123456
    11 The complete list is QQ
  • 相关阅读:
    Identifier expected after this token
    需要整理的
    Context
    SharedPreferences
    一些常规注意事项
    一个点亮屏幕的service
    BroadcastReceiver中调用Service
    BroadcastReceiver
    Service
    微服务简介
  • 原文地址:https://www.cnblogs.com/hereisdavid/p/13771926.html
Copyright © 2011-2022 走看看