Skip to content

Instantly share code, notes, and snippets.

@arnaudmm
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnaudmm/279b84c51952c23f12cb to your computer and use it in GitHub Desktop.
Save arnaudmm/279b84c51952c23f12cb to your computer and use it in GitHub Desktop.
#!/bin/bash
itr=0
arch=0
for second in $(whisper-info.py $1 | grep -E '(retention|secondsPerPoint)' | cut -d':' -f2 | tr -d ' ');
do
if [ $((itr%2)) -eq 0 ]; then
echo -n "Archive ${arch} : "
((arch++))
fi
minute=$(echo "$second/60" | bc)
hour=$(echo "$second/60/60" | bc)
day=$(echo "$second/60/60/24" | bc)
year=$(echo "$second/60/60/24/365" | bc)
#echo ${second}s/${minute}m/${hour}h/${day}d/${year}y
declare -A array
array['s']=$second
array['m']=$minute
array['h']=$hour
array['d']=$day
array['y']=$year
min=${array['s']}
for i in "${!array[@]}"
do
# Update min if applicable
if [[ "${array[$i]}" -le $min ]]; then
if [[ "${array[$i]}" -gt 0 ]]; then
min="${array[$i]}"
unit=$i
fi
fi
done
if [ $((itr%2)) -eq 0 ]; then
echo -n "${min}${unit} with "
else
echo ${min}${unit}
fi
((itr++))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment