什么是特殊的美元符号shell变量? [英] What are the special dollar sign shell variables?
本文介绍了什么是特殊的美元符号shell变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在bash中,似乎有其举办专场,一直苦口婆心值几个变量。例如,
In Bash, there appear to be several variables which hold special, consistently-meaning values. For instance,
./myprogram &; echo $!
将返回其后台运行 myprogram
进程的PID。我知道其他人,如 $?
我认为这是当前TTY的。是否有其他人呢?
will return the PID of the process which backgrounded myprogram
. I know of others, such as $?
which I think is the current TTY. Are there others?
推荐答案
-
$ 1
,$ 2
,$ 3
.. ,是位置参数的。 -
$ @
是所有的位置参数数组样构建,{$ 1,$ 2,$ 3 ...}
。 -
$ *
是所有的位置参数的IFS扩张,$ 1 $ 2 $ 3 ...
。 -
$#
是位置参数的个数。 -
$ -
为shell设置当前的期权 -
$
PID当前shell(而不是子shell)。 -
$ _
最新的参数(或命令的绝对路径,启动后立即启动当前shell)。 -
$ IFS
是(输入)字段分隔符。 -
$?
是最新的前台管道的退出状态。 -
$!
是最新的后台命令的PID。 -
$ 1,0
是shell或shell脚本的名称。
$1
,$2
,$3
, ... are the positional parameters."$@"
is an array-like construct of all positional parameters,{$1, $2, $3 ...}
."$*"
is the IFS expansion of all positional parameters,$1 $2 $3 ...
.$#
is the number of positional parameters.$-
current options set for the shell.$$
pid of the current shell (not subshell).$_
most recent parameter (or the abs path of the command to start the current shell immediately after startup).$IFS
is the (input) field separator.$?
is the most recent foreground pipeline exit status.$!
is the PID of the most recent background command.$0
is the name of the shell or shell script.
最上面可以在特殊参数中找到的在Bash参考手册。有由shell设定所有环境变量。
Most of the above can be found under Special Parameters in the Bash Reference Manual. There are all the environment variables set by the shell.
有关一个COM prehensive指数,请参阅参考手册变量指数
For a comprehensive index, please see the Reference Manual Variable Index.
这篇关于什么是特殊的美元符号shell变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文