]> Creatis software - clitk.git/commitdiff
just cp when all txt files are identical
authorPierre Gueth <gueth@linux6.dg.creatis.insa-lyon.fr>
Tue, 10 Jul 2012 14:18:41 +0000 (16:18 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Thu, 27 Jun 2013 12:47:29 +0000 (14:47 +0200)
cluster_tools/gate_power_merge.sh

index 31f915809e547cffaebb6369ff73b7e259a9aee4..8949b35b0be6afd05f474c5ea107419531868976 100755 (executable)
@@ -272,15 +272,24 @@ function merge_dispatcher {
     then
         echo "${indent}this is a non specific txt output"
         local mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}")"
-        echo "  ${indent}catting ${mergedfile}"
-        cat ${partialoutputfiles} > "${mergedfile}" || error "error while merging"
-        return
+        local nbdifferent="$(md5sum ${partialoutputfiles} | awk '{ print $1; }' | sort | uniq | wc -l)"
+        echo "  ${indent}${nbdifferent} different files"
+        if test ${nbdifferent} -gt 1
+        then
+            echo "  ${indent}catting to ${mergedfile}"
+            cat ${partialoutputfiles} > "${mergedfile}" || error "error while merging"
+            return
+        else
+            echo "  ${indent}moving to ${mergedfile}"
+            cp "${firstpartialoutputfile}" "${mergedfile}" || error "error while merging"
+            return
+        fi
     fi
 
-    warning "unknown file type"
+    error "unknown file type"
 }
 
-echo "!!!! this is $0 v0.3h !!!!"
+echo "!!!! this is $0 v0.3i !!!!"
 
 rundir="${1?"provide run dir"}"
 rundir="$(echo "${rundir}" | sed 's|/*$||')"