Bash - Template

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

Template functionality with bash.

2 - Method

2.1 - HereDoc

with here_document

template.sh
#!/bin/bash
 
for FILE_NAME in ./test/*.xml; do
    ABSOLUTE_PATH=$(realpath "${FILE_NAME}")
    cat >conf.xml <<EOF
<?xml>
<root>
	<project name="project">
		<workflow name="wf1">
			<parameter name ="sourcefilename">${ABSOLUTE_PATH}</parameter>
		</workflow>
	</project>
</root>
EOF
done
Advertising

2.2 - Envsubst utility

See envsubst