I want give all the complete script if people have same problem / project or how will call it.
The first loop generates an HTML table from the JSON files and stores it in an HTML file. The second loop combines the result of the first loop with a template, so that you have a complete page. In the body tag, the include is simply searched for, deleted and filled with the table.
#!/bin/bash
jdata="json"
hdata="html"
template="tpl/tpl.html"
tmp="tmp"
# convert json to html
# https://stackoverflow.com/questions/51126226/combine-for-loop-with-cat-and-json2html/51126732#51126732
for file in $jdata/*.json;
do
# php
#php json.php $file > tmp/${file#*/}.html
# ruby
json2table < "${file}" > $hdata/"${file#*/}".html
done
# write html file
# https://unix.stackexchange.com/questions/32908/how-to-insert-the-content-of-a-file-into-another-file-before-a-pattern-marker
for file in html/*.html;
do
# extract Project Number for newfile
filename="$(basename -- "$file")"
extension="${filename#*.}"
filename="${filename%.*}"
# save the project number
NO="$(grep "No" $jdata/$filename | sed 's/[^0-9]*//g')"
OUT="$NO.html"
# write new html file
sed 's/include/$x/g' tpl/tpl.html | x="$(<$file)" envsubst '$x' > html/$OUT
done
Thank you for help & Nice day
Silvio