Reference for shell scripting
2016-03-01 17:22
621 查看
${var} 和 $var的区别
http://stackoverflow.com/questions/8748831/when-do-we-need-curly-braces-in-variables-using-bash
正常情况下都可以,特殊情况下需要用花括号来区分变量名和其他的字符
“==”和 “=” 的区别
http://stackoverflow.com/questions/2600281/what-is-the-difference-between-operator-and-in-bash
正常情况下都可以使用,最好使用 “==”
[] 、 [[]] 、 test 、 ((number compare only)) 都可以用来判断条件
set / setenv / export /declare 的区别
export (in ksh/sh):exported var is accessible by all the shells or processes invoked by the original shell (an environment value)
set (in csh): set a local variable
setenv (in csh): set an environment variable
http://www.theunixschool.com/2010/04/what-is-difference-between-export-set.html
declare is used to declare variables and give them attribute
boolean expressions
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
[ -a File ]
[ -d dir ]
[ -z String ]
[ -n String ]
[ Integer1 OP Interger2 ] "OP" is one of -eq, -ne, -lt, -le, -gt or -ge
test exit status:
[ $? -eq 0 ]
Regular expressions may also be used in comparisons:
if [[ "$gender" == f* ]]
shell expansion
http://ss64.com/bash/syntax-expand.html
Arithmatic Operation
http://www.tldp.org/LDP/abs/html/arithexp.html
z=$((z+3))
let z=z+3
http://stackoverflow.com/questions/8748831/when-do-we-need-curly-braces-in-variables-using-bash
正常情况下都可以,特殊情况下需要用花括号来区分变量名和其他的字符
“==”和 “=” 的区别
http://stackoverflow.com/questions/2600281/what-is-the-difference-between-operator-and-in-bash
正常情况下都可以使用,最好使用 “==”
[] 、 [[]] 、 test 、 ((number compare only)) 都可以用来判断条件
set / setenv / export /declare 的区别
export (in ksh/sh):exported var is accessible by all the shells or processes invoked by the original shell (an environment value)
set (in csh): set a local variable
setenv (in csh): set an environment variable
http://www.theunixschool.com/2010/04/what-is-difference-between-export-set.html
declare is used to declare variables and give them attribute
boolean expressions
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
[ -a File ]
[ -d dir ]
[ -z String ]
[ -n String ]
[ Integer1 OP Interger2 ] "OP" is one of -eq, -ne, -lt, -le, -gt or -ge
test exit status:
[ $? -eq 0 ]
Regular expressions may also be used in comparisons:
if [[ "$gender" == f* ]]
shell expansion
http://ss64.com/bash/syntax-expand.html
Arithmatic Operation
http://www.tldp.org/LDP/abs/html/arithexp.html
z=$((z+3))
let z=z+3
相关文章推荐
- Linux下Shell脚本执行PHP报错:Could not open input file
- 使用xshell远程登录ubuntu使用vi编辑不能使用删除键方向键
- hbase filter shell用法
- linux初学之6——shell基础
- shell 初始化linux系统脚本
- Azure PowerShell 1.0.0以上版本在中国Azure使用的注意事项
- Linux shell中的竖线(|)——管道符号
- shell基础
- Linux shell 之 提取文件名和目录名的一些方法
- xshell中按backspace乱码问题
- android执行shell命令,top 命令解析
- Shell脚本编程30分钟入门
- LAMP及LNMP测试环境快速构建(yum版)
- HBase 常用Shell命令
- Windows平台shellcode开发入门(三)
- Windows平台shellcode开发入门(二)
- Windows平台shellcode开发入门(一)
- Java调用Linux下的shell命令并将结果以流的形式返回
- Shell函数
- 接触shell list