From 249ee9b2ffe9f3dff0b725d368e1a35b32011329 Mon Sep 17 00:00:00 2001 From: pierre gueth Date: Mon, 7 Mar 2011 11:40:13 +0100 Subject: [PATCH] stat file unittest --- cluster_tools/mergeStatFile.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cluster_tools/mergeStatFile.sh b/cluster_tools/mergeStatFile.sh index 20eb20a..ed8ea2a 100755 --- a/cluster_tools/mergeStatFile.sh +++ b/cluster_tools/mergeStatFile.sh @@ -1,6 +1,5 @@ #!/bin/bash set -u -set -e function usage { echo "$0 -i -j -o " @@ -16,12 +15,18 @@ IN1=$2 IN2=$4 RESULT=$6 + +test -f ${IN1} && test -f ${IN2} || usage + TMP=`mktemp ./temp-XXXXXXX` +echo "merging stat file" for PARAM in `awk '$1 == "#" {print $2}' ${IN1}` do + echo "merging ${PARAM}" V1=`awk -v P=${PARAM} '$2 == P {print $4}' ${IN1} ` V2=`awk -v P=${PARAM} '$2 == P {print $4}' ${IN2} ` R=`echo "${V1} + ${V2}" | bc` - echo "# ${PARAM} = ${R}" >> ${TMP} + test -z "${R}" && continue + echo "# ${PARAM} = ${R}" >> ${TMP} done mv -f ${TMP} ${RESULT} -- 2.47.1