|
发表于 2005-9-27 21:58:08
|
显示全部楼层
Understanding following three types of conditions tests will be good for you 
When you login(bash), your .bash_profile will be read, if you define some alias, etc. in your .bashrc, here is a way for it to be invoked.
1. String comparisons
-n str1
str1 is not null (has length greater than 0)
-z str1
str1 is null (has length 0)
2. File checking
-d file
file exists and is a directory
-e file
file exists
-f file
file exists and is a regular file (i.e., not a directory or other special type of file)
-r file
You have read permission on file
-s file
file exists and is not empty
-w file
You have write permission on file
-x file
You have execute permission on file, or directory search permission if it is a directory
-O file
You own file
-G file
file's group ID matches yours (or one of yours, if you are in multiple groups).
file1 -nt file2
file1 is newer than file2a
file1 -ot file2
file1 is older than file2
3.Integer Conditionals
-lt
Less than
-le
Less than or equal
-eq
Equal
-ge
Greater than or equal
-gt
Greater than
-ne
Not equal |
|