Linux中变量$#,$@,$0,$1,$2,$*,$$,$?的含义
来源:互联网 发布:enum class java 编辑:程序博客网 时间:2024/05/01 01:02
Linux中变量$#,$@,$0,$1,$2,$*,$$,$?的含义:
$# 是传给脚本的参数个数
$0 是脚本本身的名字
$1 是传递给该shell脚本的第一个参数
$2 是传递给该shell脚本的第二个参数
$@ 是传给脚本的所有参数的列表
$* 是以一个单字符串显示所有向脚本传递的参数,与位置变量不同,参数可超过9个
$$ 是脚本运行的当前进程ID号
$? 是显示最后命令的退出状态,0表示没有错误,其他表示有错误
exmp:
[kernel@localhost test]$ cat varible
#!/bin/sh
echo "---------------------------------------"
echo "The number of parameters: $#"
echo "The name of the script itself: $0"
echo "First parameter: $1"
echo "second parameter: $2"
echo "All parameters: $@"
echo "Show parameters list: $*"
echo "Show process id: $$"
echo "Show exit stat: $?"
echo "---------------------------------------"
#!/bin/sh
echo "---------------------------------------"
echo "The number of parameters: $#"
echo "The name of the script itself: $0"
echo "First parameter: $1"
echo "second parameter: $2"
echo "All parameters: $@"
echo "Show parameters list: $*"
echo "Show process id: $$"
echo "Show exit stat: $?"
echo "---------------------------------------"
运行结果:
[kernel@localhost test]$ sh varible hello word
---------------------------------------
The number of parameters: 2
The name of the script itself: varible
First parameter: hello
second parameter: word
All parameters: hello word
Show parameters list: hello word
Show process id: 10628
Show exit stat: 0
---------------------------------------
---------------------------------------
The number of parameters: 2
The name of the script itself: varible
First parameter: hello
second parameter: word
All parameters: hello word
Show parameters list: hello word
Show process id: 10628
Show exit stat: 0
---------------------------------------
0 0
- Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
- Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
- Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
- Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
- Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
- Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
- Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
- Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
- Linux中变量$#,$@,$0,$1,$2的含义
- Linux中变量$#,$@,$0,$1,$2的含义
- Linux中变量$#,$@,$0,$1,$2的含义
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- Linux中变量$#,$@,$0,$1,$2的含义
- linux中shell变量$#,$@,$0,$1,$2的含义解释:
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- checked连文字一起选中
- 《unix高级环境编程》线程——线程基本概述
- Android EventBus实战 没听过你就out了
- IOS 在页面编辑中完成编辑后退出 键盘
- SQL Server 权限管理
- Linux中变量$#,$@,$0,$1,$2,$*,$$,$?的含义
- iOS开发之多线程技术(NSThread、OperationQueue、GCD)
- SAXParseException: cvc-complex-type.2.4.c
- 快速学会linux根文件系统制作
- 每天一个linux命令(23):Linux 目录结构
- 应用程序框架实战十二:公共操作类开发技巧(初学者必读)
- Centos6.0 通过devtoolset-2工具安装gcc 4.8
- 数据存储之SharedPreferences
- 使用viewpager,actionbar,fragment时正确导入android-support-v4.jar的方法