Help with BASH IF statement

Discussion in 'Shell Script' started by woodson2, Jun 29, 2011.

  1. woodson2

    woodson2 New Member

    Jun 29, 2011
    Likes Received:
    Trophy Points:
    I have a useradd bash script which requests the user enter an e-mail address for the user being created. This is so the user receives his username/password in an e-mail when his/her account is created.

    Currently this part of the code is very simple:

    echo Enter the users e-mail address
    read ADDRESS

    What i'm finding is that sometimes when the operators run the script they are entereing blank information. How can I put a if statement in place that enforces they enter an e-mail address format.

    I tried the following code but it doesn't work. The idea was to at least verify they are using the @ symbol.

    if [[ $string != "@" ]] ; then
    echo You have entered an invalid e-mail address!
    exit 1
    do something

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice