Files
mastering-unix-ss/chapter2/function_elapsed_time
Fabio Scotto di Santolo 4cc88d2f6e initial commit
2020-07-28 19:28:25 +02:00

18 lines
376 B
Plaintext
Executable File

elasped_time ()
{
# This elapsed_time function is for Bash shell
SEC=$1
(( SEC < 60 )) && echo -e "[Elasped time: \
$SEC seconds]\c"
(( SEC >= 60 && SEC < 3600 )) && echo -e \
"[Elasped time: $(( SEC / 60 )) min $(( SEC % 60 )) sec]\c"
(( SEC > 3600 )) && echo -e "[Elasped time: \
$(( SEC / 3600 )) hr $(( (SEC % 3600) / 60 )) min \
$(( (SEC % 3600) % 60 )) sec]\c"
}