标志-o和-L在bash中的含义是什么

时间:2011-05-05 12:37:22

标签: bash file

我有bash脚本的一部分

如果[! -e $ f -o -L $ f];然后

其中$ f是文件名

我知道-e意味着“存在”,但我找不到-o和-L意味着什么

3 个答案:

答案 0 :(得分:2)

翻译成程序员英语,文件if文件$f不存在(-e)或文件(-o} $f )是symbolic link-L),然后......“

man bash有更多详情。

答案 1 :(得分:1)

-o:如果启用了shell选项“OPTIONNAME”,则为True。

-L:如果FILE存在且为符号链接,则为真。

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

答案 2 :(得分:1)

嗯,这很有意思。我们首先定义[内置:

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

...然后我们有条件表达式的定义,用于这个内置:

`-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::).

显然这里的意思是第一个(如果文件不存在或是链接),但我不确定为什么会这样。

相关问题