Chinaunix首页 | 论坛 | 博客
  • 博客访问: 60426
  • 博文数量: 17
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 160
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-07 11:16
文章分类

全部博文(17)

文章存档

2011年(1)

2009年(16)

我的朋友

分类: LINUX

2009-01-15 15:40:57

[ expression ] 用于test操作

n1 -eq n2 Check if n1 is equal to n2.
n1 -ge n2 Check if n1 is greater than or equal to n2.
n1 -gt n2 Check if n1 is greater than n2.
n1 -le n2 Check if n1 is less than or equal to n2.
n1 -lt n2 Check if n1 is less than n2.
n1 -ne n2 Check if n1 is not equal to n2.
str1 = str2 Check if str1 is the same as string str2.
str1 != str2 Check if str1 is not the same as str2.
str1 < str2 Check if str1 is less than str2.
str1 > str2 Check if str1 is greater than str2.
-n str1 Check if str1 has a length greater than zero.
-z str1 Check if str1 has a length of zero.
-d file Check if file exists and is a directory.
-e file Checks if file exists.
-f file Checks if file exists and is a fi
le.

-r file Checks if file exists and is readable.
-s file Checks if file exists and is not empty.
-w file Checks if file exists and is writable.
-x file Checks if file exists and is executable.
-O file Checks if file exists and is owned by the current user.
-G file Checks if file exists and the default group is the same as the current user.
file1 -nt file2 Checks if file1 is newer than file2.
file1 -ot file2 Checks if file1 is older than file2.

(( expression ))
用于数值计算


val++ post-increment
val-- post-decrement
++val pre-increment
--val pre-decrement
! logical negation
bitwise negation
** exponentiation
<< left bitwise shift
>> right bitwise shift
& bitwise Boolean AND
| bitwise Boolean OR
&& logical AND
|| logical OR

[[ expression ]]
高级的字符串比较 支持正则表达式


示例:

$ cat test
#!/bin/bash
# using pattern matching
if [[ $USER == r* ]]
then
echo "Hello $USER"
else
echo "Sorry, I don’t know you"
fi
$ ./test
Hello rich
$

阅读(1883) | 评论(0) | 转发(0) |
0

上一篇:SQL--数据库触发器

下一篇:Vi命令一览表

给主人留下些什么吧!~~