
--help、man和info工具的区分 Linux and Unix 命令手册
本命令手册以实用,简洁为原则,对于已消化的内容,不附加周详的注解。
磁针石
联系方式:
QQ:37391319 gmail and gtalk: xurongzhong@gmail.com
参考资料
*http://linux.ccidnet.com/art/305/20071128/1290639_1.html
Linux操作系统为我们提供了十分方便的系统文档帮助信息。例如“--help”选项、man工具和info工具文档等。许多初学者对于这三种帮助信息的概念并不是十分了解,下面就让我们来作一些具备针对性的讲解。
“--help”选项
“--help”是个工具选项,大部分的GNU工具都具备这个选项,“--help”选项能够用来显示一些工具的信息,如在命令行中键入:
ls --help
则会显示如下的信息:
[root@DB-GATE-16 ~]# ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current
directory by default).
Sort entries alphabetically if none of
-cftuSUX nor --sort.
Mandatory arguments to long options are
mandatory for short options too.
-a,
--all do not hide
entries starting with .
-A,
--almost-all do not list
implied . and ..
--author print the
author of each file
-b,
--escape print octal
escapes for nongraphic characters
--block-size=SIZE use
SIZE-byte blocks
-B,
--ignore-backups do not list implied
entries ending with ~
-c with
-lt: sort by, and show, ctime (time of last
modification of
file status information)
with -l: show
ctime and sort by name
otherwise:
sort by ctime
“man”工具
Man工具能够显示系统手册页中的内容,这些内容大多数都是对命令的解释信息。通过查看系统文档中的man页能够得到程式的更多相关主题信息和Linux的更多特性。man是很实用的一种工具,当您在使用到某一个并不熟悉的命令时,man命令会显得很有用。
当需要了解某个工具更为周详的信息时,能够使用命令man后跟工具名的方法来实现。
如在命令行中键入:
$ man ls
则会显示如下的信息:
# man ls
LS(1) User Commands
LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about
the FILEs (the
current directory by default). Sort entries alphabetically if none of
-cftuSUX nor --sort.
Mandatory arguments to long options are mandatory for short options too.
-a, --all
do not hide entries starting with
.
-A, --almost-all
do not list implied . and ..
--author
print the author of each file
-b, --escape
print octal escapes for
nongraphic characters
--block-size=SIZE
use SIZE-byte blocks
按下space键能够显示下一屏的文本信息;按下q键则会退出man并返回到shell的提示符下。也能够利用pageup和pagedown来进行滚动浏览。
“info”显示工具信息
Info工具是个基于菜单的超文本系统,由GNU项目研发并由Linux发布。info工具包括一些关于Linux shell、工具、GNU项目研发程式的说明文档。
如在命令行中键入:
# info ls
File: coreutils.info, Node: ls invocation, Next: dir invocation, Up: Directory listing
10.1 `ls’: List directory contents
==================================
The `ls’ program lists information about
files (of any type, including
directories). Options and file arguments can be intermixed
arbitrarily, as usual.
For non-option command-line arguments that are directories, by
default `ls’ lists the contents of
directories, not recursively, and
omitting files with names beginning with
`.’. For other non-option
arguments, by default `ls’ lists just the
file name. If no non-option
argument is specified, `ls’ operates on the
current directory, acting
as if it had been invoked with a single
argument of `.’.
By
default, the output is sorted alphabetically, according to the
locale settings in effect. (1) If standard
output is a terminal, the
output is in columns (sorted vertically)
and control characters are
output as question marks; otherwise, the
output is listed one per line
and control characters are output as-is.
则会显示如下的信息:
(以上的信息来自可编辑文档,不同的linux版本显示的结果可能会不同。)
当出现以上的信息内容后:
按下?键,能够列出info窗口中的相关命令。
按下SPACE键,能够在菜单项中进行滚动浏览。
三者的比较:
“--help”选项并不是个“单独”的工具。作为一种命令的选项,他能够用来修改工具或命令的工作方式。命令的选项通常由一个或两个连字符后跟一个或多个字母来指定。选项出现在所调用的工具名后,用空格隔开。工具的其他参数都跟在选项后,也用空格隔开。“--help”选项就像分页程式“|
less”相同,他所提供的是一种快捷、高效的帮助。
Man和info就像两个集合,他们有一个交集部分,但和man相比,info工具可显示更完整的最新的GNU工具信息。若man页包含的某个工具的概要信息在info中也有介绍,那么man页中会有“请参考info页更周详内容”的字样。通常情况下,man工具显示的非GNU工具的信息是唯一的,而info工具显示的非GNU工具的信息是man页内容的副本补充。
|