LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 900|回复: 4

请问下面这段条件句意义

[复制链接]
发表于 2005-9-27 16:32:24 | 显示全部楼层 |阅读模式
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

##### 这里 -f 这个参数是什么意思?   好像除了 -f 之外 还有 x ,z 等等,他们都是什么意思呢
##### 还有 ~/.bashrc, 的 ~ 是什么含意?

# User specific environment and startup programs

JAVA_HOME=/usr/java/j2sdk1.4.2_09
CLASS_PATH=.JAVA_HOME/lib/dt.jarJAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/binHOME/binPATH

export JAVA_HOME
export CLASS_PATH
export PATH
unset USERNAME


-------------------------------

初学者问题,谢谢指教。
发表于 2005-9-27 17:00:47 | 显示全部楼层
help test

简单说就是家目录
回复 支持 反对

使用道具 举报

发表于 2005-9-27 17:45:32 | 显示全部楼层
-f 我觉得可能是检查文件是否为普通文件(也就是说不是文件夹)
~应该是指家目录,也就是/HOME
我也是新手,不知道对不对,清高说指点
回复 支持 反对

使用道具 举报

发表于 2005-9-27 20:45:53 | 显示全部楼层
-f 是用来测试一个文件是否存在并且是否是常规文件
~/.bash_rc 是指你的Home目录下的.bash_rc文件
回复 支持 反对

使用道具 举报

发表于 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
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表