1

当我遇到以下情况时,我正在移植另一个 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 中的字符串有什么作用?

4

3 回答 3

3

从 bash shell 中的“帮助测试”:

  -c FILE        True if file is character special.
  -x FILE        True if the file is executable by you.
于 2012-07-03T15:16:48.660 回答
3

// 人工测试

   -c FILE
          FILE exists and is character special

   -x FILE
          FILE exists and execute (or search) permission is granted
于 2012-07-03T15:16:53.880 回答
3

引用man test

   -c FILE
          FILE exists and is character special

   -x FILE
          FILE exists and execute (or search) permission is granted
于 2012-07-03T15:16:54.867 回答