Help on string comparison in bash script...
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 Code:
$ ./strcomp.sh abc Thanks |
I think you need && in that first statement, not ||.
Suppose $1 is 254. Then the first half of the statement is false. But the second half is true because 254 != 255. Similarly if $1 is 255, the first half becomes true (255 != 254) but the second half becomes false. Since you have used or logic, either half-statement being true will give an error message. With and logic, you will only get an error if both halves are true. |
Quote:
|
All times are GMT -5. The time now is 11:50 PM. |