]> Creatis software - clitk.git/blob - cluster_tools/mergeStatFile.sh
Debug RTStruct conversion with empty struc
[clitk.git] / cluster_tools / mergeStatFile.sh
1 #!/bin/bash
2 set -u
3
4 function usage {
5         echo "$0 -i <file1> -j <file2> -o <result>"
6         exit 1
7 }
8
9 if [ $# != 6 ]
10 then
11         usage
12 fi
13
14 IN1=$2
15 IN2=$4
16 RESULT=$6
17
18
19 test -f ${IN1} && test -f ${IN2} || usage
20
21 TMP="$(mktemp)"
22 echo "merging stat file"
23 for PARAM in `awk '$1 == "#" {print $2}' ${IN1}`
24 do
25         echo "merging ${PARAM}"
26         V1=`awk -v P=${PARAM} '$2 == P {print $4}' ${IN1} `
27         V2=`awk -v P=${PARAM} '$2 == P {print $4}' ${IN2} `
28         R=`echo "${V1} + ${V2}" | bc`
29         test -z "${R}" && continue
30         echo "# ${PARAM} = ${R}" >> ${TMP}
31 done
32 mv -f ${TMP} ${RESULT}