jeudi 21 janvier 2016

Comparing date and time in bash

I want to compare two date&time variables:

2016-01-21 17:15:06.614852743 +0300

I am trying this:

MODDATE_INIT=$(stat -c %y /home/user/my_file)
if [ $(stat -c %y /home/user/my_file) -lt  $MODDATE_INIT ]; then cat my_file; fi"

I get error:

bash: [: too many arguments What I am doing wrong? Please, help me to fix my script.

Aucun commentaire:

Enregistrer un commentaire