0

I have got the date from a log file in the format YYYY-mm-dd HH:MM:SS, in a script i am trying to get its epoch value and then print it into another log file:

time_extract=$(tac /home/test.log | grep -m1 "finished" | awk '{print $1 " " $2}')
epoch_last_time=$(date -d $time_extract +%s)
echo $epoch_last_time >> epoch_times.log

But i get nothing.

I executed the command outside the script and i got its epoch value. The date i get from log is 2021-06-02 13:38:00 and the epoch result is 1622659080.

How can i get the value by executing it in a shell?

0 Answers0