且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

语法错误:文件意外结束(预计" Fi无线网络和QUOT;)

更新时间:2022-10-19 11:32:15

尝试猫TESTFILE 后添加一个分号。例如:

 阅读:
    如果[-e TESTFILE]然后猫TESTFILE;科幻

或者

 阅读:
    测试-r TESTFILE&放大器;&安培;猫TESTFILE

I am writing a makefile in bash and I have a target in which I try to find if a file exists and even though I think the syntax is correct, i still gives me an error.

Here is the script that I am trying to run

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

I am using tabs so that is not a problem.

The error is (when I type in: "make read")

if [ -e testFile] ; then \
        cat testFile \
        fi
/bin/sh: Syntax error: end of file unexpected (expecting "fi")
make: *** [read] Error 2

Try adding a semicolon after cat testFile. For example:

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

alternatively:

read:
    test -r testFile && cat testFile