From f630bef3b5a549ae5092e24f7f00576ac95af8cd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 16:15:00 +0100 Subject: [PATCH] Finally simplify the time calculations! According to http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html a shell must be able to do modulus (=remainder). Zsh, bash and dash confirm this and thus I can save another line and get rid of a very ugly one. Signed-off-by: Nico Schottelius --- ccollect.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 4b8214f..ba91e49 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -560,14 +560,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi fi - # Calculation + # + # Time calculation + # end_s="$(${SDATE})" - full_seconds="$((${end_s} - ${begin_s}))" hours="$((${full_seconds} / 3600))" - seconds="$((${full_seconds} - (${hours} * 3600)))" - minutes="$((${seconds} / 60))" - seconds="$((${seconds} - (${minutes} * 60)))" + minutes="$(((${full_seconds} % 3600) / 60))" + seconds="$((${full_seconds} % 60))" _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" ) | add_name