Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 检查是否存在两个文件(在shell脚本中)_File_Shell - Fatal编程技术网

File 检查是否存在两个文件(在shell脚本中)

File 检查是否存在两个文件(在shell脚本中),file,shell,File,Shell,我正在编写一个shell脚本,并尝试检查是否存在两个文件。 以下是脚本示例: #!/bin/bash if [[ [ -e File1Name ] -a [ -e File2Name ] ]] then echo Yes el echo No fi 得到 script: line 5: conditional binary operator expected script: line 5: syntax error near `-e' script: line 5: `if [[ [

我正在编写一个shell脚本,并尝试检查是否存在两个文件。 以下是脚本示例:

#!/bin/bash

if [[ [ -e File1Name ] -a [ -e File2Name ] ]]
then
  echo Yes
el
  echo No
fi
得到

script: line 5: conditional binary operator expected
script: line 5: syntax error near `-e'
script: line 5: `if [[ [ -e CA ] -a [ -e CA-draw ] ]]'
我的脚本和hot有什么问题吗?

两个[[和]都是命令;您需要选择其中一个,并仅与if一起使用。

两个[[和]都是命令;您需要选择其中一个,并仅与if一起使用

if [ -e File1Name -a -e File2Name ]
then
    echo Yes
else
    echo No
fi