编写程序来检查给定文件是否存在

时间:2018-03-12 03:00:07

标签: linux

此程序错误

echo enter the file name
read fname
If [-a $fname] 
then
   echo "$num is negative"
else
   echo "cannot find a file"

错误是:

bsccs.sh: line 3: [-a: command not found
cannot find a file

1 个答案:

答案 0 :(得分:1)

你需要一个空间:

if [ -a $fname ]

此外,'如果'无效。它必须是小写的。