Chinaunix首页 | 论坛 | 博客
  • 博客访问: 298415
  • 博文数量: 240
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 50
  • 用 户 组: 普通用户
  • 注册时间: 2016-08-04 18:14
文章分类

全部博文(240)

文章存档

2017年(8)

2014年(4)

2013年(15)

2012年(4)

2011年(14)

2010年(55)

2009年(140)

我的朋友

分类: LINUX

2009-05-24 02:00:13

 

可以通过 man test 获得更加详细的内容!

-b file 若文件存在且是一个块特殊文件,则为真
-c file 若文件存在且是一个字符特殊文件,则为真
-d file 若文件存在且是一个目录,则为真
-e file 若文件存在,则为真
-f file 若文件存在且是一个规则文件,则为真
-g file 若文件存在且设置了SGID位的值,则为真
-h file 若文件存在且为一个符合链接,则为真
-k file 若文件存在且设置了"sticky"位的值
-p file 若文件存在且为一已命名管道,则为真
-r file 若文件存在且可读,则为真
-s file 若文件存在且其大小大于零,则为真
-u file 若文件存在且设置了SUID位,则为真
-w file 若文件存在且可写,则为真
-x file 若文件存在且可执行,则为真
-o file 若文件存在且被有效用户ID所拥有,则为真
-L file 若文件为符号链接,则为真
 
-z string 若string长度为0,则为真
-n string 若string长度不为0,则为真
string1 = string2 若两个字符串相等,则为真
string1 != string2 若两个字符串不相等,则为真
 
int1 -eq int2 若int1等于int2,则为真
int1 -ne int2 若int1不等于int2,则为真
int1 -lt int2 若int1小于int2,则为真
int1 -le int2 若int1小于等于int2,则为真
int1 -gt int2 若int1大于int2,则为真
int1 -ge int2 若int1大于等于int2,则为真
 
expr1 -a expr2 若expr1和expr2都为真则整式为真
expr1 -o expr2 若expr1和expr2有一个为真则整式为真

file1 -nt file2 若file1 比 file2 新,则为真
file1 -ot file2 若file1 比 file2 旧,则为真

 

详细请参考: man test

 

实例:

#!/bin/bash
# Backs up all files modify in 24 hours in current directory.

if [ $# != 1 ]
then
  echo "Usage: `basename $0` filename"
  exit 1
fi


echo "Please wait..."
tar cvf - `find . -mtime -1 -type f -print` > $1.tar
gzip $1.tar
exit 0

 
 
 
阅读(968) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~