gpt4 book ai didi

bash - 语法错误 : end of file unexpected (expecting "fi")

转载 作者:行者123 更新时间:2023-11-29 08:48:07 29 4
gpt4 key购买 nike

我正在用 bash 编写一个 makefile,我有一个目标,我试图在其中查找文件是否存在,即使我认为语法是正确的,我仍然给我一个错误。

这是我要运行的脚本

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

关于bash - 语法错误 : end of file unexpected (expecting "fi"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/764908/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com