I have a bunch of files, where template tags are used. I want to list all the different template tags used in all of the files.
This is my used bash script, which gives no match...
for f in EHS/*.html; do
value=`cat ${f}`;
[[ $value =~ "({%.*?%})" ]]
if [[ ${BASH_REMATCH[0]} ]]; then
echo "Found: ${BASH_REMATCH[0]}";
fi
done;
This is a snippet from one of the html files:
<p>
The ordernumber is: {%OrderNumber%}<br>
The partnumer is: {%PartNumber%}
</p>
So my goal is to just return all of the different tags used...
grep -o "{%[^%]*%}"would be more natural to get all the matches like that from the file. In Bash, it is combersome to extract multiple matches.=~inside[[...]], literal string matching is triggered, it is not regarded as a regex. You could useif [[ $s =~ \{%[^%]*%} ]];but you will find a single match only.