我想检查这两个文件是否存在,但我得到了
test.sh: line 3: [: missing `]'
谁能看出问题所在?
#!/bin/sh
if [ -f .ssh/id_rsa && -f .ssh/id_rsa.pub ]; then
echo "both exist"
else
echo "one or more is missing"
fi
最佳答案
尝试添加一个额外的方括号。
if [[ -f .ssh/id_rsa && -f .ssh/id_rsa.pub ]]; then
https://stackoverflow.com/questions/8971012/
相关文章:
linux - 在 bash 脚本中使用 curl 并获取 curl : (3) Illegal c
python - 如何从 subprocess.Popen() 获取输出。 proc.stdout.
linux - shell 脚本 : Run function from script over s
c++ - 在 64 位 Linux 操作系统上编译 32 位程序导致 fatal error
linux - 是否可以使用 shell 脚本递归地创建文件夹?
linux - Hadoop:«错误:未设置 JAVA_HOME»