开发者

what does flags -o and -L means in bash

I have s开发者_JAVA百科uch part of bash script

if [ ! -e $f -o -L $f ] ; then

where $f is filename

I know that -e means "exist" but I cannot find what -o and -L means


Translated to programmer English, it's "if the file ($f) does not exist (-e) or (-o) the file ($f) is a symbolic link (-L), then ..."

man bash has more details.


-o : True if shell option "OPTIONNAME" is enabled.

-L : True if FILE exists and is a symbolic link.

http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html


Hmm, this is interesting. We have first the definition of the [ builtin:

`EXPR1 -o EXPR2'
      True if either EXPR1 or EXPR2 is true.

... and then we have the definition of Conditional expression which are used for this builtin:

`-o OPTNAME'
     True if the shell option OPTNAME is enabled.  The list of options
     appears in the description of the `-o' option to the `set' builtin
     (*note The Set Builtin::).

Obviously here the intended meaning is the first one (if the file does not exist or is a link), but I'm not sure why this works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜