Checking for a valid MAC Address

I have a ksh script and would like to validate a MAC address that is input by the user:
00:14:4F:FC:00:49
example:

MAC=`/usr/bin/ckint -p "Enter MAC address"`
echo $MAC
echo " "

Obviously chkint will not work, but does anyone have any suggestions?

Thanks

$ echo A2:12:DF | tr -d "[:digit:]" | tr -d [:ABCDEF]

$ echo A2:12:DF:2Z | tr -d "[:digit:]" | tr -d [:ABCDEF]
Z

So, any output would mean an invalid character.

Ive never used chkint, but this should work after the mac is input

MAC=$(echo $MAC | sed "s/\(.*\)/\L\1/")
case $MAC
in 
  [0-9a-f][0-9a-f]:[0-9a-z][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f])
    echo "Valid MAC"
  ;;
  *) echo "Try again"
  ;;
esac
#!/bin/ksh93

while :
do
   read MAC?"Enter MAC address: "
   case "$MAC" in
       ({2}([[:xdigit:]]){5}(:{2}([[:xdigit:]])))
       break;;
   esac
   echo "Invalid MAC address"
done

`(' unexpected..........

What is the purpose of the : after while?

Thanks

It is equivalent to "while true" in this shell script. You can use "while true" - the more common and documented syntax - instead of "while :" if you so wish.

Not too much luck with that code, I have never used xdigit before.....

Obviously you are not using Korn Shell 93 then.

The following will work for bash

#!/bin/bash

while true
do
   read -p "Enter MAC address: "  MAC
   case "$MAC" in
     [[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]])
       break;;
   esac
   echo "Invalid MAC address"
done

Thanks for the snippet....... No, I am not using Korn Shell 93, but ksh........
It works great for bash can it be modified for ksh? I will try....

The script may or may not work for your version of ksh. There are several version of ksh in common use. ksh88 is the original Korn Shell. pdksh is the public domain version of ksh88. It does not seen to be actively maintained. Solaris uses a heavily modified version of ksh88.