date

[root@book sh]# date
五 12月 10 16:38:27 CST 2004

-----------------------------------------------------------------------------------

[root@book sh]# date +%Y
2004

-----------------------------------------------------------------------------------

[root@book sh]# date +%m
12

-----------------------------------------------------------------------------------

[root@book sh]# date +%d
10

------------------------------------------------------------------------------------

[root@book sh]# date +%H
16

-----------------------------------------------------------------------------------

[root@book sh]# date +%M
27

----------------------------------------------------------------------------------
%s   seconds since `00:00:00 1970-01-01 UTC' (a GNU extension)
[root@book sh]# date +%s
1102667810

----------------------------------------------------------------------------------
%a   locale's abbreviated weekday name (Sun..Sat)
[root@book sh]# date +%a


%A   locale's full weekday name, variable length (Sunday..Saturday)
[root@book sh]# date +%A
星期五

--------------------------------------------------------------------------------
%b   locale's abbreviated month name (Jan..Dec)
[root@book sh]# date +%b
12月

%B   locale's full month name, variable length (January..December)
[root@book sh]# date +%B
十二月

-------------------------------------------------------------------------------

%c   locale's date and time (Sat Nov 04 12:02:33 EST 1989)
[root@book sh]# date +%c
2004年12月10日 星期五 16时44分58秒

%C   century (year divided by 100 and truncated to an integer) [00-99]
[root@book sh]# date +%C
20

-----------------------------------------------------------------------------
%d   day of month (01..31)
[root@book sh]# date +%d
10

%D   date (mm/dd/yy)
[root@book sh]# date +%D
12/10/04

----------------------------------------------------------------------------

%e   day of month, blank padded ( 1..31)
[root@book sh]# date +%e
10

-------------------------------------------------------------------------------
%F   same as %Y-%m-%d
[root@book sh]# date +%F
2004-12-10

%x   locale's date representation (mm/dd/yy)
[root@book sh]# date +%x
2004年12月10日
-------------------------------------------------------------------------------
the 2-digit year corresponding to the %V week number
[root@book sh]# date +%g
04

the 4-digit year corresponding to the %V week number
[root@book sh]# date +%G
2004

-------------------------------------------------------------------------------
hour (00..23)
[root@book sh]# date +%H
16

hour (01..12)
[root@book sh]# date +%I
04

%k   hour ( 0..23)
%l   hour ( 1..12)

-------------------------------------------------------------------------------
day of year (001..366)
# date +%j
345

---------------------------------------------------------------------------------
%r   time, 12-hour (hh:mm:ss [AP]M)
[root@book sh]# date +%r
05:26:31 下午

%R   time, 24-hour (hh:mm)
[root@book sh]# date +%R
17:26

---------------------------------------------------------------------------------
%p   locale's upper case AM or PM indicator (blank in many locales)
[root@book sh]# date +%p
下午

%P   locale's lower case am or pm indicator (blank in many locales)
[root@book sh]# date +%P
下午

------------------------------------------------------------------------------
%S   second (00..60); the 60 is necessary to accommodate a leap second
[root@book sh]# date +%S
36

----------------------------------------------------------------------------
%T   time, 24-hour (hh:mm:ss)
[root@book sh]# date +%T
17:28:55

%X   locale's time representation (%H:%M:%S)
[root@book sh]# date +%X
17时33分25秒
----------------------------------------------------------------------------
%u   day of week (1..7);  1 represents Monday
[root@book sh]# date +%u
5

%w   day of week (0..6);  0 represents Sunday
[root@book sh]# date +%w
5

%U   week number of year with Sunday as first day of week (00..53)
[root@book sh]# date +%U
49

%V   week number of year with Monday as first day of week (01..53)
[root@book sh]# date +%V
50

-----------------------------------------------------------------------------
%z   RFC-822 style numeric timezone (-0500) (a nonstandard extension)
[root@book sh]# date +%z
+0800

%Z   time zone (e.g., EDT), or nothing if no time zone is determinable
[root@book sh]# date +%Z
CST

 » 相关连接:
清除^M Bash最常见的激活模式是交互式和非 Bash中的变量 Bash内建参数
Bash内建指令集 Bash提示符号 流程控制select 流程控制if
流程控制case awk总结 awk教程 awk使用示例
 » 本栏目最新帖:
 » 精华帖:

Powered by PHPWind v6.0 Code © 2003-08