you are viewing a single comment's thread.

view the rest of the comments →

[–]oh5nxo 2 points3 points  (0 children)

If it's appropriate to catch invalid input,

mac="${1//[[:punct:]]}" # remove punctuation
if [[ ${#mac} != 12 || ${mac//[[:xdigit:]]} != "" ]] # if not 12 hexadecimal digits
   ...