How to get the current date value in epoch i.e., number of days elapsed since 1970-1-1. I need solution in unix shell script.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update: The answer previously posted here linked to a custom script that is no longer available, solely because the OP indicated that
date +'%s'didn’t work for him. Please see UberAlex’ answer and cadrian’s answer for proper solutions. In short:For the number of seconds since the Unix epoch use
date(1)as follows:For the number of days since the Unix epoch divide the result by the number of seconds in a day (mind the double parentheses!):