lincoln@ubuntu:~$
Display all 2187 possibilities? (y or n)
过去,每个命令程序采用各自的方式来使用命令行选项,这带来了一些混乱。如下面这些名使用参数选项的方式:
lincoln@ubuntu:~$ tar cvfB /tmp/file.tar 1024
lincoln@ubuntu:~$ dd if=/dev/fd0 of=/tmp/file.dd bs=18k
lincoln@ubuntu:~$ ps aux
lincoln@ubuntu:~$ gcc --help
lincoln@ubuntu:~$ ls -lstr
lincoln@ubuntu:~$ ls -l -s -t -r
所以,如有机会编写命令行,建议在应用程序中,所有的命令开关都应以一个短横线开头,其后包含单个字母或数字。如果需要,不带后续参数的选项可以在一个短横线后归并到一起。最好也能为单字符开关增加一个更长的、更有意义的开关名,如gcc -h与gcc --help
命令如此之多,命令行选项的方式又各异,以致难以一一熟记,所幸只需以理解“在什么情况下应该要使用哪方面的命令”为准来对待即可。而至于如何使用具体的命令,可寻求“在线帮助文件”的帮助。
* man page
man是manual的简写,查看如何使用date这个命令时,可以如下操作:
lincoln@ubuntu:~$man date
DATE(1) User Commands DATE(1) /*括号中的数字①*/
NAME /*命令全名及其简单用途②*/
date - print or set the system date andtime
SYNOPSIS /*基本语法概述*/
date [OPTION]... [+FORMAT] /*注意格式前面有个+号*/
date [-u|--utc|--universal][MMDDhhmm[[CC]YY][.ss]]
DESCRIPTION /*详细描述参数用法*/
Display the current time in the givenFORMAT, or set the system date.
-d, --date=STRING
display time described by STRING,not `now'
………………中间省略…………………
# use opposite case if possible
After any flags comes an optional field width, as a decimal number; then anoptional modifier, which is either E to use the locale's alternaterepresentations if available, or O to use the locale's alternate numeric symbols ifavailable.
DATE STRING /*对STRING的解释*/
The --date=STRING is a mostly free format human readable date string such as"Sun, 29 Feb 2004 16:21:42-0800" or "2004-02-29 16:21:42"or even "next Thursday". Adate string may contain items indicating calendar date, time of day, time zone, day of week, relativetime, relative date, and numbers. Anempty string indicates the beginning of the day. The date string format is more complex than iseasily documented here but is fully described in the info documentation.
AUTHOR /*命令的作者*/
Written by David MacKenzie.
REPORTING BUGS /*报告错误*/
Report date bugs tobug-coreutils@gnu.org
GNU coreutils home page:http://www.gnu.org/software/coreutils/
General help using GNU software: http://www.gnu.org/gethelp/
COPYRIGHT /*GPL*/
Copyright (c) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or laterhttp://gnu.org/licenses/gpl.html.
This is free software: you are free tochange and redistribute it. There is NOWARRANTY, to the extent per-mitted bylaw.
SEE ALSO /*其他获取与date相关信息的方式*/
The full documentation for date ismaintained as a Texinfo manual. If theinfo and date programs are per-mitted erly installed at your site, the command
infocoreutils 'date invocation'
should giveyou access to the complete manual.
GNUcoreutils 7.4 March 2010 DATE(1)
Manual page date(1) line 158/182 (END)
① DATE(1)括号中的数字代表的意义
② man page大致分成以下几个部分
③ man page中常用的按键
* info page
在所有的UNIX like系统当中,都可以利用man来查询命令或者是相关文件的用法;但在Linux里面则又额外提供了一种在线求助的方法,就是利用info。
Info与man的用途差不多,只是man是一下子输出一堆信息,而infopage是将文件数据拆成一个一个的段落,每个段落用自己的页面来撰写,并且在各个页面中还有类似网页的“超链接”来跳到各不同的页面中,每个独立的页面也被称为一个节点。
root@ubuntu:~# info date
File: coreutils.info, Node: date invocation, Next:uname invocation, Prev: arch invocation, Up: System context
22.3 `date': Print or set system date andtime
==============================================
Synopses:
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [ MMDDhhmm[[CC]YY][.ss] ]
Invoking `date' with no FORMAT argument is equivalent to invoking it
with a default format that depends on the`LC_TIME' locale category.
In the default C locale, this format is`'+%a %b %e %H:%M:%S %Z %Y'',
so the output looks like `Thu Mar 3 13:47:51 PST 2005'.
Normally, `date' uses the time zone rules indicated by the `TZ'
environment variable, or the system defaultrules if `TZ' is not set.
*Note Specifying the Time Zone with `TZ':(libc)TZ Variable.
Ifgiven an argument that starts with a `+', `date' prints the
current date and time (or the date and timespecified by the `--date'
option, see below) in the format defined bythat argument, which is
similar to that of the `strftime' function. Except for conversion
specifiers, which start with `%',characters in the format string are
printed unchanged. The conversion specifiers are describedbelow.
Anexit status of zero indicates success, and a nonzero value indicates failure.
* Menu:
* Time conversion specifiers:: %[HIklMNpPrRsSTXzZ]
* Date conversion specifiers:: %[aAbBcCdDeFgGhjmuUVwWxyY]
* Literal conversion specifiers:: %[%nt]
* Padding and other flags:: Pad with zeros, spaces, etc.
* Setting the time:: Changing the system clock.
* Options for date:: Instead of the current time.
* Date input formats:: Specifying date strings.
* Examples of date:: Examples.