#!/bin/bash rm all for f in assets/css/*.css; do printf "<style type='text/css' >\n" >> all cat $f >> all printf "</style>\n <!-----$f---->" >> all echo "$f copied" done
I am using this code to copy all css content with the file names into a html file. This code works fine.
But the way strings are concatenated, it is mixing up the templates and the logic.
Can this be written more elegantly that has a template string like,
<style type='text/css'> ${cssContent} </style><!---${cssFileName}--->
and an associative array like,
{ 'cssContent' : 'file content', 'cssFileName' : 'file name' }
and a function as,
format(templateStr, assocArr)
that returns me the formatted string?