bash - 如何对 /etc/network/interface 进行排序?
问题描述
我是新手,我需要使用 /etc/network/interfaces 文件订购环回、静态、dhcp,如下静态地址:
auto eth1
iface eth1 inet static
address 192.168.11.3
netmask 255.255.255.0
gateway 192.168.11.1
它看起来像这样:
Interface=eth1, Type=Static, Direction=192.168.11.3, Mask=255.255.255.0, Gateway=192.168.11.1
对于 dhcp 地址:
auto eth0
iface eth0 inet dhcp
它看起来像这样:
Interface=eth0, Type=Dhcp
对于环回:
auto lo
iface lo inet loopback
它看起来像这样:
Interface=lo, Type=loopback
我尝试如下解决它,但它不起作用
if [ grep -r "static" /etc/network/interfaces ]; then
gawk '{print "Interface=" $2 ", " "Type=" "Static" ", " "Direction=" $2 ", " "Mask=" $2 ", " "Gateway=" $2}' /etc/network/interfaces
解决方案
推荐阅读
- wordpress - ACF 克隆字段 - 设置默认值
- node.js - 在 node.js 中使用 node-fetch 重用 TCP 连接
- r - 是否可以根据下一张图片时间是否在前一张图片的 2 分钟内对 csv 中的图像创建日期进行排序/分组?
- c - 递归链表?我认为
- python - 无法在 Windows 上使用 python kivy 创建 .exe(Pyinstaller)
- c# - 使用 c# 将条件格式复制到 Outlook 邮件正文中
- python - 使用 GeoPandas 创建头部图,调整后的图像很小 - 如何更改比例?
- c# - 如何配置 routeConfig.cs 在根域之后直接接受输入
- vba - 如何获取特定字体颜色内的字符串(向文本添加内容,而不是更改颜色) Find.Text 为空
- apache-kafka - Kafka 未重新启动 - 已清除日志、磁盘空间。重新启动但它一次又一次地关闭