zoukankan      html  css  js  c++  java
  • Linux Shell函数

    介绍

    正文

    $?

    $?是shell变量,表示"最后一次执行命令"的退出状态.0为成功,非0为失败.切记:$?永远表示shell命令最后一次执行后的退出状态,当函数执行完毕后,如果又执行了其它命令,则$?不再表示函数执行后的状态,而表示其它命令的退出状态

     

    $$ 
    Shell本身的PID(ProcessID) 
    $! 
    Shell最后运行的后台Process的PID 
    $? 
    最后运行的命令的结束代码(返回值) 
    $- 
    使用Set命令设定的Flag一览 
    $* 
    所有参数列表。如"$*":"$1 $2 … $n"的形式输出所有参数。 
    $@ 
    所有参数列表。如"$@"以多行的形式"$1" "$2""$n" 输出所有参数。 
    $# 
    添加到Shell的参数个数 
    $0 
    Shell本身的文件名 
    $1~$n 
    添加到Shell的各参数值。$1是第1参数、$2是第2参数…。 

    例:

    vim a.sh

     #!/bin/bash
      printf "The complete list is %s
    " "$$"
      printf "The complete list is %s
    " "$!"
      printf "The complete list is %s
    " "$?"
      printf "The complete list is %s
    " "$*"
      printf "The complete list is %s
    " "$@"
      printf "The complete list is %s
    " "$#"
      printf "The complete list is %s
    " "$0"
      printf "The complete list is %s
    " "$1"
      printf "The complete list is %s
    " "$2"

     

    总结

    备注:

        作者:pursuer.chen

        博客:http://www.cnblogs.com/chenmh

    本站点所有随笔都是原创,欢迎大家转载;但转载时必须注明文章来源,且在文章开头明显处给明链接。

    《欢迎交流讨论》

  • 相关阅读:
    用django搭建自己的博客
    python模块调用
    python常用函数
    ubuntu不能访问windows中的文件
    更改ubuntu下mysql的密码
    重拾代码,加油
    java 接收 char字符型
    Git基础
    flask中'bool' object has no attribute '__call__'问题
    基于python的flask的应用实例注意事项
  • 原文地址:https://www.cnblogs.com/chenmh/p/5383542.html
Copyright © 2011-2022 走看看