Linux -x和-c字符串比较选项的作用是什么?
我正在移植另一个shell脚本时遇到以下问题:Linux -x和-c字符串比较选项的作用是什么?,linux,string,bash,sh,hp-ux,Linux,String,Bash,Sh,Hp Ux,我正在移植另一个shell脚本时遇到以下问题: if [[ ! -x $DVDREC ]]; then print "ERROR: $DVDREC not found. Exiting ..." exit 1 fi if [[ ! -c ${DVDDEV} ]]; then print "ERROR: ${DVDDEV} not found. Exiting ..." exit 1 fi 我想知道-c和-x选项实际上对存储的字符串做了什么 在DVDREC和DVDDEV中?来自
if [[ ! -x $DVDREC ]]; then
print "ERROR: $DVDREC not found. Exiting ..."
exit 1
fi
if [[ ! -c ${DVDDEV} ]]; then
print "ERROR: ${DVDDEV} not found. Exiting ..."
exit 1
fi
我想知道-c和-x选项实际上对存储的字符串做了什么
在DVDREC和DVDDEV中?来自bash shell中的“帮助测试”:
在bash shell中的“帮助测试”中:
//人工测试
-c FILE
FILE exists and is character special
-x FILE
FILE exists and execute (or search) permission is granted
//人工测试
-c FILE
FILE exists and is character special
-x FILE
FILE exists and execute (or search) permission is granted
引用人试验:
引用人试验:
谢谢你的帮助。我对Linux操作系统相当陌生,所以我不知道有一个用于测试的手册页。@Justin:没问题。对于不熟悉bash的人来说,
[
和测试之间的关系并不明显。所以这是一个好问题。@justin-手册页不是针对您将要使用的测试命令的。将首先使用测试内置或[
。在您的情况下,您使用的是bash关键字[[
,而不是命令。标志是一样的。谢谢你的帮助。我对Linux操作系统相当陌生,所以我不知道有一个用于测试的手册页。@Justin:没问题。对于那些不熟悉[
和test
并不明显。因此这是一个好问题。@justin-手册页不是针对您将要使用的test命令的。将首先使用test
内置或[
。在您的情况下,您使用的是bash关键字[
,而不是命令。标志是相同的。
-c FILE
FILE exists and is character special
-x FILE
FILE exists and execute (or search) permission is granted