seconds_to_time.sh added

This commit is contained in:
Ruzicka Pavel 2016-09-19 04:10:02 +02:00
parent 36735dfaa2
commit d32a9cb746

15
seconds_to_time.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
function displaytime {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
[[ $D > 0 ]] && printf '%d days ' $D
[[ $H > 0 ]] && printf '%d hours ' $H
[[ $M > 0 ]] && printf '%d minutes ' $M
[[ $D > 0 || $H > 0 || $M > 0 ]] && printf 'and '
printf '%d seconds\n' $S
}
displaytime $1