Bsh 特殊变量

jc posted @ 2012年4月16日 05:15 in Linux小贴士 , 1298 阅读

bsh具有几个特殊的变量,记录以备查阅:

$#    --    脚本参数的个数

$?     --    最近管道的退出状态,零为执行成功

$-      --    shell set指令设置的环境变量

$$     --    shell脚本的进程号,子shell进程号?

$!      --    shell脚本中最近后台执行的程序进程号,或者最近管道指令的进程号。

$*      --    传递给当前进程的参数,当置于一双引号中时展开为单一参数(一字符串)。

$@     --   传递给当前进程的参数,当置于一双引号中时各自展开为单独的参数(多个字符串)。

$0      --    shell简本自身名字,相当于C中的argv。

$[1-9]     --   shell脚本参数,相当于C中的argv + [0-9]。当大于9时需要用括号括住。

Avatar_small
Gail Liles 说:
2020年10月07日 00:36

Program and all stages are filed for the top of the reforms for the changes. The list of the program and essaywriter is fixed for the trends for the clients. Program and planes widely followed for the assignment for the deflection for the terms.

Avatar_small
jnanabhumiap.in 说:
2024年1月21日 19:54

JNANABHUMI AP provides all latest educational updates and many more. The main concept or our aim behind this website has been the will to provide resources full information on each topic which can be accessed through Internet. To ensure that every readers get’s what important and worthy about the topic they search and link to hear from us. jnanabhumiap.in Jnanabhumi AP is a startup by passionate webmasters and bloggers who have passion to provide engaging content which is accurate, interesting and worthy to read. We are mope like a web community where you can find different information’s, resources, topics on day to day incidents or news. We provide you the finest of web content on each and every topics possible with help of editorial and content team.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter