i have a variable 200612 the last two digits of this variable should be between 1 and 12, it should not be greater than 12 or less than 1 (for ex: 00 or 13,14,15 is not accepted) how do i check for this conditions in a unix shell script.
thanks Ram
Nevemind; misread question.
Carl
[[ ${var#????} -lt 13 ]] && [[ ${var#????} -gt 0 ]] ....
var=200612 last2=${var#"${var%??}"} if [ ${last2#0} -lt 1 ] || [ ${last2#0} -gt 12 ] then printf "INVALID %s\n" "$var" >&2 fi