Last active
April 1, 2025 19:02
-
-
Save angelbladex/03d96e69fb249a00ce48 to your computer and use it in GitHub Desktop.
Validate mac address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [[ ! -n "$1" ]]; then | |
| echo "Error: Missing Mac Address" | |
| exit 1 | |
| fi | |
| if [[ "$1" =~ ^([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$ ]]; then | |
| echo "Valid MAC Address ($1)" | |
| exit 0 | |
| else | |
| echo "Error: Invalid MAC Address: $1" | |
| echo "Format accepteds:" | |
| echo " XX:XX:XX:XX:XX:XX" | |
| echo " XX-XX-XX-XX-XX-XX" | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment