Create files from templates, substitutions in middle of other words
1
vote
2
answers
535
views
Is there a way to convince m4 to replace a macro in the middle of a word?
I would like this file, day.m4:
define(Sat,Cat)dnl
Saturday
and this command:
m4 day.m4
to produce this output:
Caturday
As shown, m4 will not do this.
Alternatively, is there a way to get sed to perform multiple substitutions simultaneously? That is, without passing over the file for each substitution.
I can pipe a bunch of sed commands together or use a combination of sed and m4 and that's not so bad but if there's a convenient way to do this with one input file and one command that'd be preferable.
Any other commonly available tool would be fine too.
My goal is to use this for creating files from templates. Most of the tokens that are to be replaced are space separated.
Asked by Praxeolitic
(1688 rep)
Sep 16, 2014, 10:30 PM
Last activity: Nov 27, 2018, 05:30 PM
Last activity: Nov 27, 2018, 05:30 PM