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

查看:143
本文介绍了什么是特殊的美元符号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秒登录
发送“验证码”获取 | 15天全站免登陆