我正在编写一个 bash 脚本,并编写了一个 if 子句来检查多个文件是否存在。我使用的子句是 -
if [[ -f /home/step/certs/root_ca.crt && -f /home/step/certs/intermediate_ca.crt && -f /home/step/secrets/root_ca_key && -f /home/step/secrets/intermediate_ca_key && -f /home/step/config/ca.json && -f /home/step/config/defaults.json]]; then
echo 'Existing Certificate Authority found!\nUsing the existing certificate authority...'
它给出了这个错误-
syntax error in conditional expression: unexpected token `;'
我尝试删除
;
并遇到另一个语法错误 -
syntax error in conditional expression
检查多个文件是否存在的正确语法是什么?
错误位于
/home/step/config/defaults.json]];
。
你必须将其重写为
/home/step/config/defaults.json ]];
。您错过了 ]]
之前的必填空格。