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?
-d
or-e
)", i.e. "not-d
and not-e
". Voting to close as off-topic (typo). – Kusalananda Feb 12 '19 at 19:58