Venky
Venky

Reputation: 21

Date comparison in shell script

In my script to monitor expiry date of .der certificates, I managed to take out the expiry date of the certificate but when I compare with the current date, its not happening. The expiry date has m/d/yy format, I compared that with current date of the same format(mm/dd/yy) its failing. When I grep the expiry date, is the result has the same date format or it changes to string? Can you please help me with this?

Upvotes: 0

Views: 645

Answers (1)

glenn jackman
glenn jackman

Reputation: 247230

d=7/7/11
dd=$(IFS=/; printf "%02d/%02d/%02d" $d)
echo $dd  # => 07/07/11

Upvotes: 1

Related Questions