As stated in the title i'd like to create multiple files from a template and replace a fixed keyword on-the-fly
if i do
$ sed s/XX/{01..05}/g templates/pXX.conf
i get kinda close, since i get an correct output for first result, but an error for numbers 02-04.
since it's not neccessary in icinga to separate each configuration file (but it would be a bonus), it's ok to get the result into a single output-file.
Example:
//template.conf
object Host "pXX" {
display_name = "RasPi XX"
...
}
this now should result into:
//p01.conf <- ascending filenames would be a bonus
object Host "p01" {
display_name = "RasPi 01"
...
}
//p02.conf
object Host "p02" {
display_name = "RasPi 02"
...
}
// and so on
i'm pretty sure this is easy done by using any sort of script with a loop inside
while $i < number: read file; replace content; output file;
i'm just curious if this can be done using some single line commands
for i in 01 02 03; do sed "s/XX/$i/" template.conf > template$i.conf; done