什么是特殊的美元符号shell变量? [英] What are the special dollar sign shell variables?

查看:131
本文介绍了什么是特殊的美元符号shell变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Bash中,似乎有几个变量具有特殊的,始终如一的值。例如,

In Bash, there appear to be several variables which hold special, consistently-meaning values. For instance,

./myprogram &; echo $!

将返回背景 myprogram 。我知道其他人,例如 $?,我认为是目前的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 ... li>
  • $#是位置参数的数量。

  • $ - 为shell设置的当前选项。

  • $$ pid当前shell(而不是subshel​​l)。

  • $ _ 最近的参数(或启动后立即启动当前shell的命令的abs路径)。
  • $ IFS 是(输入)字段分隔符。

  • $? 是最近的前台管道退出状态>
  • $!是最新背景命令的PID。

  • $ 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参考手册中的href =https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html =noreferrer>特殊参数。所有由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.

      有关综合索引,请参阅参考手册变量索引

      For a comprehensive index, please see the Reference Manual Variable Index.

      这篇关于什么是特殊的美元符号shell变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆