regex - Regular expression to replace a part of a config file -
i made shell script automate process of loading file snmp daemon steps.
in end need edit conf file on server, , realize need use regular expressions.
i have made file named zfiles.txt have content need insert range of lines.
snmptt_conf_files = <<end /etc/snmp/file-1 /etc/snmp/file-2 ... ... /etc/snmp/file-n end
i need replace everithing between snmptt_conf_files = <<end
, end
content of zfiles.txt
.
btw if can provide resources learn regular expressions, appreciate it.
thanks in advance
sed '/snmptt_conf_files = <<end/,/end/{ # here-doc block: /^end$/b # if @ end skip rest /<<end/!d # if not first line delete , skip rest... else insert file: r zfiles.txt }' input
as resource, mastering regular expressions jeffrey e f friedl solid book.
Comments
Post a Comment