#!/bin/bash tokens=("DEFAULTVALUE" "DESCRIPTION" "SHORTFORM" "TYPEINFO") greptoken=("CurrentValueMap" "DescriptionMap" "ShortFormMap" "TypeMap") for file in `find . -name '*.def'`; do #file="AnalysisAction/MolecularVolumeAction.def" # get token TOKEN=`grep TOKEN $file | awk -F" " {'print $3'} | tr -d \"`; echo "Grep for $TOKEN ... "; # add to file echo -e -n "\n// finally the information stored in the ActionTrait specialization\n" >>$file; i=0; while [ $i -lt 4 ]; do grep -c ${greptoken[$i]}.*$TOKEN MapOfActions.cpp if [ $? -eq 0 ]; then echo "#define ${tokens[$i]} `grep -m 1 -nH ${greptoken[$i]}.*$TOKEN MapOfActions.cpp | awk -F" = " {'print $2'} | tr -d \;`" >>$file; else echo "#undef ${tokens[$i]}" >>$file; fi ((i+=1)); done done