Saturday, January 9, 2016

Linux bash script to extract IPv4 address

hostname -I | tr ' ' '\n' | grep '[0-9]' | grep -v '127\.0\.0\.'
or
ifconfig | grep "inet addr" | cut -f 2 -d ":" | cut -f 1 -d " " | grep -v '127\.0\.0\.'

1 comment:

Unknown said...

ip addr | grep -v 127.0.0 | perl -n -e 'if (m/inet ([\d\.]+)/g) { print $1 }'

Post a Comment

一些有用的网站

Windows系统安装界面认不到硬盘,加载RST驱动: https://iknow.lenovo.com.cn/detail/419926.html 纯净版Flash: https://gitlab.com/cleanflash/installer/-/releases    ...