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

时间:2016-02-21 22:22:49

标签: 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行看到任何错误引用

SCRIPT:

#!/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

1 个答案:

答案 0 :(得分:2)

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