Create New C++ Class
Use input redirection instead of cat | ...

Instead of cat somefile | somecommand, you should use input redirection, for example:

xgengen bash &lt; Samples/template_bash_CMakeLists.txt | bash - &gt; CMakeLists.txt


The advantage of this is that you're running one fewer process (no more cat).

Use modern style command substitution $(...)

Don't use old style `...` command substitution.
Use the modern and better $(...) style.

Simplify sed + awk pipelines when possible

This looks very complicated, and it's suspicious to have both sed and awk in the same pipeline:

echo $_class | sed -e 's/\([A-Z]\)/_\1/g' | awk '{printf toupper($0)} END{printf "_H_";}'


You can simplify using a single awk command:

echo $_class | awk '{gsub("[A-Z]", "_\&amp;"); printf toupper($0) "_H_"}'


Use here-strings instead of echo | ...

Similar to using input redirection instead of cat | ...,
in Bash it's better to replace echo | ... with here-strings using &lt;&lt;&lt;,
rewriting the above example as:

awk '{gsub("[A-Z]", "_\&amp;"); printf toupper($0) "_H_"}' &lt;&lt;&lt; $_class


Use alternative regex pattern separator to improve readability

When a regular expression pattern contains /,
using such patterns with the s/// operator becomes tedious and hard to read,
because of the escapes.
To improve readability, it's often good to use an alternative pattern separator.
So for example instead of this:

sed 's/\.\//  /'


You can do this instead to avoid escaping /:

sed 's|\./|  |'


The benefit is more obvious when you have multiple / in the pattern.
In this example the difference might be negligible.

Simplify regex

The s/// here can be simplified:

sed -e 's/\(.*\)/#include \"\.\.\/\1\"/g'


To this:

sed -e 's/.*/#include "..\/&amp;"/'


That is:


No need to capture .* in \(...\), you can access the matched string directly with &amp;
No need to escape . in replacement, as it has no special meaning there
No need to escape " within single-quoted strings in Bash
Since the pattern matches the entire line, no need for the g flag