Help with read/if command.

Discussion in 'Getting Started' started by Malohhree, Jul 9, 2014.

  1. Malohhree

    Malohhree New Member

    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    What is wrong with this?

    #!/bin/bash

    echo "Who are you?"
    read NAMES
    if [ "$NAMES" == "Palmer" ] ; then
    echo "Oh, hey! I love you, baby!"
    elif [ "$NAMES" == "Mallory" ] ; then
    echo "Hello, me!"


    When I run it, it asks me who I am, to which I reply with either Mallory or Palmer. Then it says "line 9: syntax error: unexpected end of file"

    ryanvade likes this.
  2. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,398
    Likes Received:
    454
    Trophy Points:
    83
    you didn't end the if.
    Code:
    #!/bin/bash
    
    echo "Who are you?"
    read NAMES
    if [ "$NAMES" == "Palmer" ] ; then
    echo "Oh, hey! I love you, baby!"
    elif [ "$NAMES" == "Mallory" ] ; then
    echo "Hello, me!"
    fi;
    

Share This Page