Skip to main content
1 of 2

Checking first argument of a script if it is -e or -d

I am writing a bash shell script at the moment and one of the specifications is that I need to print an error message if the first argument, $1, is not -e or -d, this is what I have done:

if [ "$1" != "-e" ] || [ "$1 != "-d" ]; then
        echo "Error: First argument must be either -e or -d"
        exit 1
fi

this does not seem to work however, as even if i used -e or -d for the first argument, this error message is still printed. What am I doing wrong and how do I fix this?