首页 > 代码库 > date、man、hwclock、echo、printf
date、man、hwclock、echo、printf
date:
ntp:network time protocol 网络时间协议
硬件时钟
系统时钟
获得命令使用帮助
help 查看一个内部命令使用帮助,查看一个内部命令帮助一般使用该命令
help COMMOND
2.man 查看外部命令使用帮助
man COMMOND 查看使用手册
COMMOND --help
man是分章节的,常见章节有8个:
[root@redhat ~]# man ls
LS(1) User Commands LS(1)
(1)用户命令(/bin、/usr/bin、/usr/local/bin等路径下的命令)
(2)系统调用
(3)库用户
(4)特殊文件(设备文件)
(5)文件格式(解释某一个命令配置文件的语法 【例:passwd中以:隔开的每一段字符含义】)
(6)游戏说明
(7)不便归类的杂项
(8)管理命令(管理员才有权限使用/sbin/、/usr/sbin、/usr/local/sbin等路径下的命令)
whatis COMMOND:查看一个命令会出现在哪些章节中
[root@redhat ~]# man date
SYNOPSIS<>命令用法说明
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
[]:可省略
|:多选一
<>:必选
{}:分组
……:可多次出现
DESCRIPTION<>命令用法详尽说明,可能包括每一个命令选项的意义
DESCRIPTION<>命令用法详尽说明,可能包括每一个命令选项的意义
OPTIONS<>有的命令会把每一个选项的意义写在此处
FILES<>此命令相关的配置文件
BUGS<>bug的反馈
EXAMPLES<>使用示例
SEE ALSO<>另外参照
翻屏:
向后翻一屏:SPACE
向前翻一屏:b
向后翻一行:enter
向前翻译行:k
查找:
/string:向后查找
n:下一个
N:前一个
?string:向前查找
n:前一个
N:后一个
FORMAT controls the output. Interpreted sequences are:
%% a literal %
%a locale‘s abbreviated weekday name (e.g., Sun)<>星期几缩写
[root@redhat ~]# date +%a
Tue
%A locale‘s full weekday name (e.g., Sunday)<>星期几完整的
[root@redhat ~]# date +%a
Tuesday
%b locale‘s abbreviated month name (e.g., Jan)
[root@redhat ~]# date +%b
Jun
%B locale‘s full month name (e.g., January)
[root@redhat ~]# date +%a
June
%d day of month (e.g, 01)
%D date; same as %m/%d/%y
%e day of month, space padded; same as %_d
%F full date; same as %Y-%m-%d
%g last two digits of year of ISO week number (see %G)
%G year of ISO week number (see %V); normally useful only with %V
%h same as %b
%H hour (00..23)
%I hour (01..12)
%j day of year (001..366)
%k hour ( 0..23)
%l hour ( 1..12)
%m month (01..12)
%M minute (00..59)
%n a newline<>新的一行
%N nanoseconds (000000000..999999999)
%p locale‘s equivalent of either AM or PM; blank if not known
%P like %p, but lower case
%r locale‘s 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%s seconds since 1970-01-01 00:00:00 UTC<>1970年1月1号到现在经过时间,除以86400
%S second (00..60)
%t a tab
%T time; same as %H:%M:%S
%u day of week (1..7); 1 is Monday
%U week number of year, with Sunday as first day of week (00..53)
%V ISO week number, with Monday as first day of week (01..53)
%w day of week (0..6); 0 is Sunday
%W week number of year, with Monday as first day of week (00..53)
%x locale‘s date representation (e.g., 12/31/99)
%X locale‘s time representation (e.g., 23:13:48)
%y last two digits of year (00..99)
%Y year
hwclock
-s 硬件时钟到系统,同步以后系统时间为硬件时间
-w 系统时钟到迎检,同步以后硬件时间为系统时间
cal 日历
echo
Options:
-n do not append a newline<>不换行输出,默认换行输出
-e enable interpretation of the following backslash escapes<>逃逸字符
-E explicitly suppress interpretation of backslash escapes
\b backspace<>退格
[root@redhat ~]# echo "You is a shadiao.\bnonono"
You is a shadiao.\bnonono
[root@redhat ~]# echo -e "You is a shadiao.\bnonono"
You is a shadiaononono
\v vertical tab<>纵向制表符
[root@redhat ~]# echo "You is a shadiao.nonono"
You is a shadiao.nonono
[root@redhat ~]# echo -e "You is a shadiao.\vnonono"
You is a shadiao.
nonono
\n new line<>换行
[root@redhat ~]# echo "You is a shadiao.nonono"
You is a shadiao.nonono
[root@redhat ~]# echo -e "You is a shadiao.\nnonono"
You is a shadiao.
nonono
\t horizontal tab<>横向制表符
[root@redhat ~]# echo "You is a shadiao.nonono"
You is a shadiao.nonono
[root@redhat ~]# echo -e "You is a shadiao.\tnonono"
You is a shadiao. nonono
printf 格式化输出
本文出自 “liuqistyle” 博客,请务必保留此出处http://liuqistyle.blog.51cto.com/10991928/1939365
date、man、hwclock、echo、printf