I’m trying to see if a timestamp is expired. Which it would be, if it’s before now or empty.
exp=1662023095
NOW=$(date +%s)
if [[ -z $exp || (($exp < $NOW)) ]]; then
echo "Update token..."
else
echo "Token still valid!"
fi
The always echo "Update token…". Can someone tell me what I’m doing wrong?
>Solution :
found in the man bash:
When used with [[, the < and > operators sort lexicographically using the current locale.
Give this a try:
if [[ -z "${exp}" ]] || (( exp < NOW )) ; then
...