On Mon, Apr 26, 2010 at 10:55 AM, Martin Mensch
<address@hidden> wrote:
Til now I know how to include this config file
(with include) and how to create and write to an output file (echo >>
filename)
But how do I
- take in the contents of a file named by the
config file
- go through this file, change placeholders
controled by the config file
- copy parts several times controled by the config
file
- leave out parts controled by the config
file
You're looking for a tool like 'sed' or 'perl'. Those can of course be used from within makefiles. That said, to do all of the above you'll have to do a bit of research/learning about those tools. As a quick example, to change a config entry in a conventional config file you could do:
perl -i -pe 's|^(\s*KeyName\s*=(.*)|$1 New Value|' configfile
You can create loops which pull individual keys out and replace their values or, if you know the list of keys/values in adance, you can change several of them at once with a single perl call.
- and put the result into an echo
command?
you may also want to look into using "cat" instead of "echo". 'cat' reads from a file or stdin and simply outputs it to stdout (like echo, except that echo sends its own arguments to stdout).
--