Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Operation of date and time under linux shell

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report