zoukankan      html  css  js  c++  java
  • shell MAC 地址 校验

    /***************************************************************************************
     *                            shell MAC 地址 校验
     * 说明:
     *     要对MAC地址进行校验,记录一下正则表达式写法,有些方法在PC上验证是可行的,但到了
     * 嵌入式产品上,可能就不一定能运行了。
     *
     *                                                2016-11-15 深圳 南山平山村 曾剑锋
     **************************************************************************************/
    
    一、参考文档:
        1. BASH regex match MAC address
            http://stackoverflow.com/questions/19959537/bash-regex-match-mac-address
        2. Best way to extract MAC address from ifconfig's output
            http://stackoverflow.com/questions/245916/best-way-to-extract-mac-address-from-ifconfigs-output
    
    二、测试shell脚本如下:
        macPath=/sys/bus/i2c/devices/3-0050/eeprom
        mac=`grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' $macPath`
    
        if [ ${#mac} -eq 17 ]; then
            echo "MAC Address: $mac"
            ifconfig eth0 hw ether $mac
        else 
            ifconfig eth0 hw ether 70:b3:d5:10:6f:90
        fi
  • 相关阅读:
    (QR14)带权的DAG节点排序
    数字组合
    最长连续不重复子序列
    树状数组
    归并排序
    差分
    前缀和
    64位整数乘法
    MySQL8 常用指令
    离线及实时实操架构
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/6067010.html
Copyright © 2011-2022 走看看