20.1 shell script introduces 20.2 shell script structure and executes 20.3 date command usage 20.4 A variable in a shell script

Source: Internet
Author: User

[[Email protected] shell]# date +%y year, 4-digit
2018
[[Email protected] shell]# date +%y year, 2-digit
18
[[Email protected] shell]# date +%m Month
04
[[Email protected] shell]# date +%m M, number of minutes
57

[[Email protected] shell]# date +%d
13
[Email protected] shell]# date +%d Month Day year
04/13/18

[Email protected] shell]# date +%y%m%d
20180413

[Email protected] shell]# date +%f
2018-04-13

[[Email protected] shell]# date +%h hours
16
[[Email protected] shell]# Date +%s timestamp
1523607008
[[Email protected] shell]# date +%s second seconds
17

[Email protected] shell]# date +%t
16:12:32

[[Email protected] shell]# Date +%w day of the week
5
[Email protected] shell]# Date +%w the week of the year
15

[[email protected] shell]# date-d "-1 day"
Thu APR 16:19:26 CST 2018
[Email protected] shell]# date-d "-1 day" +%f
2018-04-12
[Email protected] shell]# date-d "-1 month" +%f
2018-03-13

[Email protected] shell]# date-d "-1 year" +%f
2017-04-13
[Email protected] shell]# date-d "-1 Years" +%f
2017-04-13

[Email protected] shell]# date-d "-1 Hour" +%t
15:22:39

[Email protected] shell]# date +%s
1523607974
[Email protected] shell]# date-d @1523607974
Fri APR 16:26:14 CST 2018

20.1 shell script introduces 20.2 shell script structure and executes 20.3 date command usage 20.4 A variable in a shell script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.