Determine number of days when the local certificate will expire using openssl in bash

CERTP=/etc/letsencrypt/archive/qwerty.md/cert4.pem
DAYSR=$(( ($(date --date="$(openssl x509 -noout -dates -in $CERTP | grep 'notAfter=' | sed 's/notAfter=//g')" +%s) - $(date +%s))/(60*60*24) ))
echo Remaining days until the expiration of the certificate: $DAYSR days