访问手机版  

Linux常用命令|Linux培训学习|考试认证|工资待遇与招聘,认准超级网工!

招聘|合作 登陆|注册

网络工程师培训

当前位置:网络工程师 > 技术课程 > linux > 热点关注 > linux常用命令

linux命令总结之date命令

时间:2019-11-17

linux命令总结之date命令

date%20根据给定格式显示日期或设置系统日期时间。print%20or%20set%20the%20system%20date%20and%20time

指令所在路径:/bin/date

date%20[OPTION]...%20[+FORMAT]

date%20[-u|--utc|--universal]%20[MMDDhhmm[[CC]YY][.ss]]

显示字符串描述的时间

显示DATEFILE文件中的每行时间

显示文件的最后修改时间

以RFC-2822兼容日期格式显示时间

-rfc-2822

以RFC-2822兼容日期格式显示时间

设置时间为string

显示或设定为Coordinated%20Universal%20Time时间格式

--help

显示date命令的帮助信息

--version

显示date命令的版本信息

要说写这位程序的 David MacKenzie老兄,真是事无巨细啊,居然整了这么多格式参数,佩服佩服。

显示字符%

星期几的缩写(Sun..Sat)

星期几的完整名称(Sunday...Saturday)

月份的缩写(Jan..Dec)

月份的完整名称(January..December)

日期与时间。只输入date指令也会显示同样的结果

世纪(年份除100后去整) [00-99]

日期(以01-31来表示)。

日期(含年月日)。

一个月的第几天 ( 1..31)

日期,同%Y-%m-%d

年份(yy)

年份(yyyy)

同%b

小时(00..23)

小时(01..12)

linux简单命令大全_linux shell 命令 大全_linux命令大全

一年的第几天(001..366)

小时( 0..23)

小时( 1..12)

月份(01..12)

分钟(00..59)

换行

纳秒(000000000..999999999)

AM or PM

am or pm

12小时制时间(hh:mm:ss [AP]M)

24小时制时间(hh:mm)

从00:00:00 1970-01-01 UTC开始的秒数

秒(00..60)

制表符

24小时制时间(hh:mm:ss)

一周的第几天(1..7); 1 表示星期一

一年的第几周linux命令大全,周日为每周的第一天(00..53)

linux简单命令大全_linux命令大全_linux shell 命令 大全

一年的第几周,周一为每周的第一天 (01..53)

一周的第几天 (0..6); 0 代表周日

一年的第几周,周一为每周的第一天(00..53)

日期(mm/dd/yy)

时间(%H:%M:%S)

年份(00..99)

年份 (1970…)

RFC-2822 风格数字格式时区(-0500)

时区(e.g., EDT), 无法确定时区则为空

1: 查看date命令帮助信息

 1 [root@Gin scripts]# date --help
 2 Usage: date [OPTION]... [+FORMAT]
 3   or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
 4 Display the current time in the given FORMAT, or set the system date.
 5 
 6   -d, --date=STRING         display time described by STRING, not `now'
 7   -f, --file=DATEFILE       like --date once for each line of DATEFILE
 8   -r, --reference=FILE      display the last modification time of FILE
 9   -R, --rfc-2822            output date and time in RFC 2822 format.
10                             Example: Mon, 07 Aug 2006 12:34:56 -0600
11       --rfc-3339=TIMESPEC   output date and time in RFC 3339 format.
12                             TIMESPEC=`date', `seconds', or `ns' for
13                             date and time to the indicated precision.
14                             Date and time components are separated by
15                             a single space: 2006-08-07 12:34:56-06:00
16   -s, --set=STRING          set time described by STRING
17   -u, --utc, --universal    print or set Coordinated Universal Time
18       --help     display this help and exit
19       --version  output version information and exit
20 
21 FORMAT controls the output.  Interpreted sequences are:
22 
23   %%   a literal %
24   %a   locale's abbreviated weekday name (e.g., Sun)
25   %A   locale's full weekday name (e.g., Sunday)
26   %b   locale's abbreviated month name (e.g., Jan)
27   %B   locale's full month name (e.g., January)
28   %c   locale's date and time (e.g., Thu Mar  3 23:05:25 2005)
29   %C   century; like %Y, except omit last two digits (e.g., 20)
30   %d   day of month (e.g, 01)
31   %D   date; same as %m/%d/%y
32   %e   day of month, space padded; same as %_d
33   %F   full date; same as %Y-%m-%d
34   %g   last two digits of year of ISO week number (see %G)
35   %G   year of ISO week number (see %V); normally useful only with %V
36   %h   same as %b
37   %H   hour (00..23)
38   %I   hour (01..12)
39   %j   day of year (001..366)
40   %k   hour ( 0..23)
41   %l   hour ( 1..12)
42   %m   month (01..12)
43   %M   minute (00..59)
44   %n   a newline
45   %N   nanoseconds (000000000..999999999)
46   %p   locale's equivalent of either AM or PM; blank if not known
47   %P   like %p, but lower case
48   %r   locale's 12-hour clock time (e.g., 11:11:04 PM)
49   %R   24-hour hour and minute; same as %H:%M
50   %s   seconds since 1970-01-01 00:00:00 UTC
51   %S   second (00..60)
52   %t   a tab
53   %T   time; same as %H:%M:%S
54   %u   day of week (1..7); 1 is Monday
55   %U   week number of year, with Sunday as first day of week (00..53)
56   %V   ISO week number, with Monday as first day of week (01..53)
57   %w   day of week (0..6); 0 is Sunday
58   %W   week number of year, with Monday as first day of week (00..53)
59   %x   locale's date representation (e.g., 12/31/99)
60   %X   locale's time representation (e.g., 23:13:48)
61   %y   last two digits of year (00..99)
62   %Y   year
63   %z   +hhmm numeric timezone (e.g., -0400)
64   %:z  +hh:mm numeric timezone (e.g., -04:00)
65   %::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)
66   %:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
67   %Z   alphabetic time zone abbreviation (e.g., EDT)
68 
69 By default, date pads numeric fields with zeroes.
70 The following optional flags may follow `%':
71 
72   -  (hyphen) do not pad the field
73   _  (underscore) pad with spaces
74   0  (zero) pad with zeros
75   ^  use upper case if possible
76   #  use opposite case if possible
77 
78 After any flags comes an optional field width, as a decimal number;
79 then an optional modifier, which is either
80 E to use the locale's alternate representations if available, or
81 O to use the locale's alternate numeric symbols if available.
82 
83 Report date bugs to bug-coreutils@gnu.org
84 GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
85 General help using GNU software: <http://www.gnu.org/gethelp/>
86 For complete documentation, run: info coreutils 'date invocation'
 上一个教程:常见LINUX命令表