Given a project template folder with variables in paths and content
tree test-projecttest-project
└── %NAME1%
└── %NAME2%
└── %NAME2%-hello.txt
2 directories, 1 file
cat test-project/%NAME1%/%NAME2%/%NAME2%-hello.txtTest project %NAME1%.%NAME2% %GREET% How are you?
Now run template.sh with variables set in the environment and a path to a template folder
mkdir -p hello
cd hello
NAME1=src NAME2=andrej/lamov GREET='hello world' ../template.sh ../test-projectIt outputs some info…
Source template: /home/andrej/code/template/test-project Target: /home/andrej/code/template/hello Variables: GREET=hello world NAME1=src NAME2=andrej/lamov Using sed: -e 's\%GREET%\hello world\g' -e 's\%NAME1%\src\g' -e 's\%NAME2%\andrej/lamov\g' Copying: %NAME1%/%NAME2%/%NAME2%-hello.txt -> src/andrej/lamov/andrej/lamov-hello.txt
And it results in the following structure
tree hellohello
└── src
└── andrej
└── lamov
└── andrej
└── lamov-hello.txt
4 directories, 1 file
cat hello/src/andrej/lamov/andrej/lamov-hello.txtTest project src.andrej/lamov hello world How are you?