ifconfig | grep ‘inet[^6]‘ | sed ‘s/^\s*//g‘ | cut -d ‘ ‘ -f2 > ips.txt
排除127开头的IP:
ifconfig | grep ‘inet[^6]‘ | sed ‘s/^\s*//g‘ | cut -d ‘ ‘ -f2 | sed ‘/^127.*/d‘ > ips.txt
Linux下提取IP至文件
原文:http://www.cnblogs.com/flowjacky/p/4368169.html