linux - 寻找匹配的 `"' shell 脚本时出现意外的 EOF

标签 linux bash shell quote

我明白了

./matrix: line 36: unexpected EOF while looking for matching `"'
./matrix: line 38: syntax error: unexpected end of file

当我尝试运行我编写的 shell 脚本时,但在第 36-38 行没有看到任何错误引用

脚本:

#!/bin/bash
RAND=$(( ( RANDOM % 10 )  + 1 ))
if [ $RAND == 1 ]
    then
        printf '\e[38;5;118m "Follow The White Rabbit"'|cowthink -f matrix
elif [ "$RAND" == 2 ]
    then
        printf '\e[38;5;118m "To deny our own impulses is to deny the very thing that makes us human."'|cowthink -f matrix
elif [ "$RAND" == 3 ]
    then
        printf '\e[38;5;118m "Neo, sooner or later you\'re going to realize just as I did that there\'s a difference between knowing the path and walking the path."'|cowthink -f matrix
elif [ "$RAND" == 4 ]
    then
        printf '\e[38;5;118m "You have to \let it all go, Neo. Fear, doubt, and disbelief. Free your mind."'|cowthink -f matrix
elif [ "$RAND" == 5 ]
    then
        printf '\e[38;5;118m "What are you waiting \for? You\'re faster than this. Don\'t think you are, know you are. Come on. Stop trying to hit me and hit me."'|cowthink -f matrix
elif [ "$RAND" = 6 ]
    then
        printf '\e[38;5;118m "I\'m trying to \free your mind, Neo. But I can only show you the door. You\'re the one that has to walk through it."'|cowthink -f matrix
elif [ "$RAND" == 7 ]
    then
        printf '\e[38;5;118m "

Tank\: So what \do you need? Besides a miracle.

Neo\: Guns. Lots of guns."'|cowthink -f matrix
elif [ "$RAND" = 8 ]
    then
        printf '\e[38;5;118m "You take the red pill - you stay \in Wonderland and I show you how deep the rabbit-hole goes."'|cowthink -f matrix
elif [ "$RAND" == 9 ]
    then
        printf '\e[38;5;118m "What is real? How \do you define \'real\'? If you\'re talking about what you can feel, what you can smell, what you can taste and see, \then \'real\' is simply electrical signals interpreted by your brain."'|cowthink -f matrix
elif [ "$RAND" == 10 ]
    then
        printf '\e[38;5;118m "Have you ever had a dream, Neo, that you were so sure was real? What \if you were unable to wake from that dream? How would you know the difference between the dream world and the real world?"'|cowthink -f matrix
fi

最佳答案

修复 ' 的转义:将所有 \' 替换为 '\''

关于linux - 寻找匹配的 `"' shell 脚本时出现意外的 EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35542886/

相关文章:

linux - 如何从命令行确定我的 KDE 桌面是否处于锁屏状态?

无法理解关于 linux 中函数调用的简单 c 代码的输出

sql - 当语法正确时,为什么PostgreSQL语句在单引号上失败?

linux - 使用 Bash 检查另一个目录中是否存在相同的文件

shell - 我应该在 POSIX shell 中使用 "test"还是 "[" "]"?

linux - 当 Bash 中 `read` 仅显示 `read(2)` 时,如何查看 `whatis` 命令的手册页?

linux - 如何判断文件是否缓存在 linux 的内存中?

linux - 测试 bash 中是否至少存在一个带有名称前缀的目录

linux - 如何使用bash中的变量内容传递给脚本中的查找?

linux - 如何使用下一个单词前没有空格的变量?