I have a file that begins with a few "include" statements, like this:
include foo.xyz
include bar.xyz
do c
do d
Suppose the file foo.xyz contains do a and the file bar.xyz contains do b. How can I write a script that replaces each include file.xyz statement with the contexts of file.xyz? I want to end up with the following output:
do a
do b
do c
do d
I tried the solution in "Replace string with contents of a file using sed" but there the filename is hard-coded. I would like the filename to be dynamically generated, depending on the include argument.
include filename.xyzwherefilename.xyzis assumed to be in the current directory. – John Wickerson Nov 11 '15 at 15:26