<分区>
我在尝试编写脚本时遇到问题。缩小并简化了代码,它给出了一个错误,即找不到命令。如果我在命令行中执行“test -f file”,它什么都不返回,没有找到命令
PATH=$1
#!/bin/bash
DIR=$1
if [[-f $PATH]]; then
echo expression evaluated as true
else
echo expression evaluated as false
fi
exit
这是我尝试运行的实际更复杂的脚本
verify()
{
if [[-f $1]]; then
VFY[$2]="f"
echo "$1 is a file"
elif [[-d $1]]
then
VFY[$2]="d"
echo "$1 is a directory"
else
VFY[$2]=0
echo -e "\r"
echo "$1 is neither a file or a directory"
echo -e "\r"
fi
}
它是一个更大的脚本的一部分,可以根据输入来移动东西。我在 CentOS 6 和 FreeBSD 上运行过这个,都给出了相同的错误“[[-f: Command not found”