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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -