我在BASH中写了一个Maxfile,我有一个目标,我试图找出一个文件是否存在,即使我认为语法是正确的,我仍然会给我一个错误。
这是我要运行的脚本

read:
        if [ -e testFile] ; then \
        cat testFile\
        fi

我正在使用标签,所以这不是问题。
错误是(当我输入“make read”时)
if [ -e testFile] ; then \
        cat testFile \
        fi
/bin/sh: Syntax error: end of file unexpected (expecting "fi")
make: *** [read] Error 2

最佳答案

尝试在cat testFile之后添加分号。例如:

read:
    if [ -e testFile ] ; then  cat testFile ; fi

或者:
read:
    test -r testFile && cat testFile

08-27 03:53