统计test.txt中非空行数
grep -c ^[^$] test.txt
或字符的使用,|是扩展的正则表达式定义的,需要加上-E选项才能使用
grep -E "a|b" test.txt
获取网卡名字
ifconfig | grep -o "^[^[:space:]]\{1,\}"
获取网卡ip地址
ifconfig | grep -o "inet addr:[0-9\.]\{1,\}" | cut -d ":" -f 2
统计test.txt中非空行数
grep -c ^[^$] test.txt
或字符的使用,|是扩展的正则表达式定义的,需要加上-E选项才能使用
grep -E "a|b" test.txt
获取网卡名字
ifconfig | grep -o "^[^[:space:]]\{1,\}"
获取网卡ip地址
ifconfig | grep -o "inet addr:[0-9\.]\{1,\}" | cut -d ":" -f 2
转载于:https://my.oschina.net/yaodaren/blog/122545