shell脚本的特殊变量
2016-10-15 15:00
465 查看
1. 单个参数 $1、$2 ......
oliver@bigdatadev:~$ more demo.sh
#!/bin/sh
echo The First argument: $1
echo The Second argument: $2
echo The Third argument: $3
oliver@bigdatadev:~$ demo.sh 10 20 30
The First argument: 10
The Second argument: 20
The Third argument: 30
oliver@bigdatadev:~$
2. 脚本名 $0
3. 参数的数量 $#
4. 所以参数 $@
5.进程号 $$
6.退出码 $?
oliver@bigdatadev:~$ more demo2.sh
#!/bin/sh
echo File Name: $0
echo PID: $$
echo Argument Count: $#
echo Artuments: $@
exit 100
oliver@bigdatadev:~$ demo2.sh 10 20 30
File Name: ./demo2.sh
PID: 3182
Argument Count: 3
Artuments: 10 20 30
oliver@bigdatadev:~$ echo $?
100
oliver@bigdatadev:~$
oliver@bigdatadev:~$ more demo.sh
#!/bin/sh
echo The First argument: $1
echo The Second argument: $2
echo The Third argument: $3
oliver@bigdatadev:~$ demo.sh 10 20 30
The First argument: 10
The Second argument: 20
The Third argument: 30
oliver@bigdatadev:~$
2. 脚本名 $0
3. 参数的数量 $#
4. 所以参数 $@
5.进程号 $$
6.退出码 $?
oliver@bigdatadev:~$ more demo2.sh
#!/bin/sh
echo File Name: $0
echo PID: $$
echo Argument Count: $#
echo Artuments: $@
exit 100
oliver@bigdatadev:~$ demo2.sh 10 20 30
File Name: ./demo2.sh
PID: 3182
Argument Count: 3
Artuments: 10 20 30
oliver@bigdatadev:~$ echo $?
100
oliver@bigdatadev:~$
相关文章推荐
- shell 脚本中的特殊变量 以及 shell 脚本的调试
- shell脚本中$#、$0、$@等特殊变量的含义
- Shell脚本学习-位置参数和特殊变量
- shell脚本中的特殊变量
- Shell基础教程,什么是Shell?Shell脚本的执行方式,Shell中的变量,Shell中的特殊变量
- [Linux] shell bash 脚本特殊变量 [大三TJB_708]
- shell脚本学习:特殊变量和C语言格式循环
- shell脚本学习第三天——特殊变量
- shell脚本基本应用(三)特殊的Shell变量
- shell脚本变量特殊字符的含义
- shell脚本及makefile中的特殊变量
- shell脚本编程之条件判断,算术运算,整数测试及特殊变量
- shell脚本之变量、变量类型、条件测试、算术运算、及特殊变量
- Shell 脚本分割变量分别赋值与sed 应用打印特殊行
- shell脚本及makefile中的特殊变量
- shell脚本和Makefile中的特殊变量
- Shell脚本中的位置变量参数(特殊字符)实例讲解
- shell 脚本编程之特殊变量
- Shell脚本中的位置变量参数(特殊字符)实例讲解
- Linux shell脚本 (三)Shell特殊变量