【发布时间】:2021-03-31 09:46:23
【问题描述】:
我想制作脚本来显示域到期的剩余天数。 我能够获得域到期日期的行,但我将其 grep 为该格式
renewal date: 2021.09.24 12:22:02
接下来我应该怎么做才能使date 命令正常工作?
现在我收到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))
【问题讨论】:
-
whoisdata:之后打印什么值? -
续订日期:2021.09.24 12:22:02
标签: linux bash date parsing whois