Added life-left script
This commit is contained in:
27
life/left.sh
Normal file
27
life/left.sh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
MINUTE=60
|
||||||
|
HOUR=$(($MINUTE * 60))
|
||||||
|
DAY=$(($HOUR * 24))
|
||||||
|
MONTH=$(($DAY * 30))
|
||||||
|
YEAR=$(($DAY * 365))
|
||||||
|
|
||||||
|
if [[ $# < 2 ]]; then
|
||||||
|
echo "Usage: $0 <birthdate> <age>"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_lifetime() {
|
||||||
|
future=$(date +%s -d "$1 + $2 years")
|
||||||
|
epoch=$(($future - $(date +%s)))
|
||||||
|
|
||||||
|
echo "Seconds until $2 years old: $epoch"
|
||||||
|
echo "Minutes until $2 years old: $(($epoch / $MINUTE))"
|
||||||
|
echo "Hours until $2 years old: $(($epoch / $HOUR))"
|
||||||
|
echo "Days until $2 years old: $(($epoch / $DAY))"
|
||||||
|
echo "Months until $2 years old: $(($epoch / $MONTH))"
|
||||||
|
echo "Years until $2 years old: $(($epoch / $YEAR))"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
print_lifetime "$1" "$2"
|
||||||
Reference in New Issue
Block a user