File 检查是否存在两个文件(在shell脚本中)
我正在编写一个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 [[ [
#!/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