如何带上一段文本。我有一个文件,我需要从“ config sys interfaces”部分获取该文件,直到第一个“ end”为止。最好的方法是使用正则表达式?
#config-version=FGVM64-5.6.3-FW-build1547-171204:opmode=0:vdom=0:user=bruno
#conf_file_ver=153884383284212
#buildno=1547
#global_vdom=1
config system global
set admin-scp enable
set admintimeout 100
set alias "FortiGate-VM64"
set hostname "000-1001-0"
set timezone 18
end
**config system interface <---------- Start
edit "port1"
set vdom "root"
set ip 192.168.0.150 255.255.255.0
set allowaccess ping https ssh http telnet
set type physical
set role wan
set snmp-index 1
next
edit "port2"
set vdom "root"
set type physical
set role wan
set snmp-index 2
next
end <------------ Stop**
config firewall schedule recurring
edit "always"
set day sunday monday tuesday wednesday thursday friday saturday
next
edit "none"
next
end
答案 0 :(得分:0)
结果应为:
config system interface
edit "port1"
set vdom "root"
set ip 192.168.0.150 255.255.255.0
set allowaccess ping https ssh http telnet
set type physical
set role wan
set snmp-index 1
next
edit "port2"
set vdom "root"
set type physical
set role wan
set snmp-index 2
next
end