Bash脚本文件/目录脚本错误

Bash脚本文件/目录脚本错误,bash,Bash,我正在制作一个程序,它将读取一个文件/目录名,并会显示它是一个文件还是一个目录。当我执行我的文件时,没有错误发生,但什么也没有发生。。。有什么想法吗 #!/bin/bash echo "Please enter the name of the file/directory" read var if test -d var then echo "It's a directory" fi if test -f var then echo "It's a file" f

我正在制作一个程序,它将读取一个文件/目录名,并会显示它是一个文件还是一个目录。当我执行我的文件时,没有错误发生,但什么也没有发生。。。有什么想法吗

#!/bin/bash
echo "Please enter the name of the file/directory"
read var
if test -d var
        then echo "It's a directory"
fi
if test -f var
        then echo "It's a file"
fi

尝试测试其值时使用
$var
如果测试-d“$var”
……谢谢