Operation of date and time under linux shell
This article mainly introduces "the operation of date and time under linux shell". In the daily operation, I believe that many people have doubts about the operation of date and time under linux shell. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "operation of date and time under linux shell". Next, please follow the editor to study!
Date +% Y%m%d-d "2 day ago"
Date +% Y%m%d-d "2 week ago"
Date +% Y%m%d-d "2 month ago"
Date +% Y%m%d-d "2 year ago"
Date-d "yesterday"
Yesterday's order was:
Yesterdayformat= `date-- date='yesterday' "+% Y-%m-%d_%H:%M:%S" `
Echo $yesterdayformat
The output format is:
2006-03-30mm 08purl 39UR 54
Tomorrow's order is:
Tomorrowformat= `date-- date='tomorrow' "+% Y-%m-%d_%H:%M:%S" `
Echo $tomorrowformat
The output format is:
2006-04-01 / 08 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 01 / 01 / 08 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 08 / 01 / 01 / 01 / 01 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 01 / 01 / 08 / 01 / 01 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 01 / 01 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 01 / 08 / 01 / 08 /
Under Linux, get the date format before or after N days:
# date-I-d'- n day' (you can get the date of N days ago in YYYY-MM-DD format)
# date-d'- n day' "+% Y%m%d" (you can get your date in the format of YYYYMMDD) # date-I-d'+ n day' (you can get the date after N days in the format of YYYY-MM-DD)
# date-d'+ n day' "+% Y%m%d" (you can get your diva date in YYYYMMDD format)
At this point, the study of "the operation of date and time under linux shell" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!