[root@centos8 ~]
GRUB_CMDLINE_LINUX="resume=UUID=7c877369-a4e8-4dc6-bcaf-b65cd5cd567b rhgb quiet net.ifnames=0"
[root@centos8 ~]
[root@centos8 ~]
以上方法centos8 centos7均可通用
sed -r 's/(GRUB_CMDLINE_LINUX.*)"$/\1 net.ifnames=0"/' /etc/default/grub
可用sed看效果,需要修改需要加 -i.bak 将原文件备份
ifconfig eth0| head -2 | tail -1 |tr -s ' '|cut -d' ' -f 3
以上方法centos6-8 均可通用
ifconfig eth0 | sed -n '2p'|sed -r 's@.*inet (.*) net.*@\1@'
ifconfig eth0 | sed -n '2p'|sed -r 's@.*(inet )(.*)( net.*)@\2@'
ifconfig eth0 | sed -r '2!d;s@.*(inet )(.*)( net.*)@\2@'
以上三种sed效果