How do I fix unexpected end of file in bash script?

11,173

Solution 1

I was, indeed, missing a double quote at the top of my script. Thanks to all for the help!

Solution 2

A good way to solve problems like this is to use a text editor that highlights code between quotes. Short of that, if the "find" feature of your text editor gives a count too, you may be able to use it to quantitatively detect start/end character symmetry problems. The highlighting from the find feature will aide your eye tremedously.

Share:
11,173
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I had much luck last time I submitted a question so here goes: I am trying to debug a somewhat large BASH script when I get the following error:

    ./test.sh: line 418: unexpected EOF while looking for matching `"'
    ./test.sh: line 427: syntax error: unexpected end of file
    

    The code below starts at line 400:

        echo "###########################################################"
        echo
    ;;
    4)
        culebra_carriers
        get_month
        get_day
        logs_cdrs
        logs_wap
        get_mdn
    
        echo
        echo "###########################################################"
        echo
        echo "Searching for activity of $mobileNumber on $MON $DAY......."
        echo
        zgrep $mobileNumber $HOME/culebrapeak/$LOGCDR/$CULEB/$MON/$WAPLOG
        echo
        echo "###########################################################"
        echo
    ;;
    esac
    done
    }
    
    clear
    main_menu
    

    How do I make this error go away? It looks like I have the double quotes in all the right places... but this is only my 4th or 5th bash script... so please go easy on me.

  • Scott Prive
    Scott Prive over 9 years
    You've made a mistake here by submitting your own answer, then accepting it as "the" answer... when Anthony gave you a pretty good answer. (You may be unfamiliar with StackOverFlow rules, but Anthony gets a deserved credit/thanks if you had accepted his answer)