#!/bin/bash OLDIFS=$IFS IFS=' ' # add paramvalids line for file in `find . -name '*.def' -exec grep -H "#define paramtypes" {} \;`; do paramfile=`echo $file | awk -F":" {'print $1'}` validline=`echo $file | sed -e "s/[^:]*://" -e "s/(\([^)]*\))/(DummyValidator< \1 >())/g" -e "s/paramtypes/paramvalids/"` if [ ! -z `grep "^#define paramtypes" $paramfile` ]; then echo -n "$paramfile :" sed -i -e "s/^\(#define paramtypes.*\)/\1\n$validline/" $paramfile #| grep --after-context=1 "#define paramdefaults" fi done IFS=$OLDIFS # append include find . -name '*.def' -exec sed -i -e "s#\(// i.e. there is an integer with variable name Z that can be found in\)#\#include \"Parameters/Validators/DummyValidator.hpp\"\n\n\1#" {} \;