I want to make script to show remaining days to domain expiration. I am able to get row with domain expiration date but i grep it to that format
renewal date: 2021.09.24 12:22:02
What should I do next to make date
command work?
Right now Im getting date: invalid date ‘+%s’
#!/bin/bash
target=$1
# Get the expiration date
expdate=$(whois $1 | egrep -i 'Expiration|Expires on|Renewal Date| head -1 ')
echo "whoisdata:"$expdate
# Turn it into seconds (easier to compute with)
expdate=$(date -d"$expdate" +%s)
# Get the current date in seconds
curdate=$(date +%s)
# Print the difference in days
echo $(((expdate-curdate)/86400))