7.2. File test operators

1、example 7-4

不懂下面的代码,这不是纯bash的代码,那是什么代码?


#This, however, is a better method:

#

#find "somedir" -type l -print0|\

#xargs -r0 file|\

#grep "broken symbolic"|

#sed -e 's/^\|: *broken symbolic.*$/"/g'

#

#but that wouldn't be pure bash, now would it.

2、一句有技巧的语句:


[ $# -eq 0 ] && directorys=`pwd` || directorys=$@

结构:

如果 (参数个数=0)返回值为真,就会继续执行:directorys=当前目录;执行成功它的exit状态为0,也是真,那么就会停止执行||(或);

如果 (参数个数=0)返回值为假,就不会执行 &&(与)了,但会执行||(或)。

3、example 7-4

[ -h "$element" -a ! -e "$element" ] ,预先知道这句的作用是找到破坏了的符号连接,但是这句的作用怎么来的不懂;

另外,[ - ]与邻近的字符之间必须有空格。

英语疑问:

1、sticky:

Commonly known as the "sticky bit," the save-text-mode flag is a special

    type of file permission.

2、absent:

"not" -- reverses the sense of the tests above (returns true if condition

    absent).

3、would:

but that wouldn't be pure bash, now would it.

One thought on “7.2. File test operators”

Comments are closed.