Hello All
I'm a mediocre level bash scripter. Following code is making me crazy. I cant understand what I'm doing wrong. I just want to make sure the parameter passed to script is either '264' or '265'.
The problem is in first if statement. The second works fine. Whats wrong in first one?
Code:
#!/bin/bash
echo "Type 1:"
if [[ "$1" != "264" || "$1" != "265" ]] ; then
echo "Parameter should be 264 or 265"
else
echo "Correct"
fi
echo "Type 2:"
if [[ "$1" == "264" || "$1" == "265" ]] ; then
echo "Correct"
else
echo "Parameter should be 264 or 265"
fi
Result is like this:
Code:
$ ./strcomp.sh abc
Type 1:
Parameter should be 264 or 265
Type 2:
Parameter should be 264 or 265
$ ./strcomp.sh 264
Type 1:
Parameter should be 264 or 265
Type 2:
Correct
$ ./strcomp.sh 265
Type 1:
Parameter should be 264 or 265
Type 2:
Correct
Why
!= in first if statement comparsion is not working?
Thanks