1.匹配到指定行,然后在上一行插入
在/etc/config/wireless文件中匹配到'sta'字符串,然后在改行的上一行插入config wifi-iface 'ap'
sed -i "/'sta'/a\config wifi-iface 'ap'" /etc/config/wireless
说明:
i:表示上一行
a:表示下一行
2.匹配到指定行,然后插入多行
在/etc/config/wireless文件中匹配到'sta'字符串,然后在该行的下一行插入如下内容:
config wifi-iface 'ap'
option device 'mt7628'
sed -i "/'sta'/a\config wifi-iface 'ap' \n option device 'mt7628'\n" /etc/config/wireless