#!/bin/bash for file in `find -name '*.def'`; do #file="TesselationAction/NonConvexEnvelopeAction.def" liste=(`grep paramtokens $file | awk -F"paramtokens " {'print $2'} | tr \( \ | tr \) \ `) command="#define paramdescriptions " i=0; while [ $i != ${#liste[*]} ]; do hits=`echo ${liste[$i]} | grep -c NAME` if [ ! $? -eq 0 ]; then grep -c DescriptionMap.*${liste[$i]} MapOfActions.cpp if [ $? -eq 0 ]; then description=`grep -m 1 DescriptionMap.*${liste[$i]} MapOfActions.cpp | awk -F"= " {'print $2'} | tr -d \;` command="$command ($description)" fi else description=`grep -m 1 DESCRIPTION $file | awk -F"DESCRIPTION " {'print $2'}` command="$command ($description)" fi ((i+=1)); done if [ $i -eq 0 ]; then command="#undef paramdescriptions" fi line=`grep -n -m 1 paramtokens $file | awk -F":" {'print $1'}` total=`wc -l $file | awk -F" " {'print $1'}` echo "line $line, total $total" head -n $line $file >$file.new echo $command >>$file.new tail -n $((total-line)) $file >>$file.new mv -f $file.new $file done