A piece of CMD

man

比如我平时一般不用zip命令,现在想知道zip怎么用,需要在手册中查询。可以直接使用man zip查询zip命令,但是由于man维护了多个区段,这样默认查询的结果是区段号最小的一条。

BSD、OS X以及Linux的man page的区段描述如下:

区段 说明
1 一般命令
2 系统调用
3 库函数,涵盖C标准函数库
4 特殊文件(通常是dev下的设备)和驱动程序
5 文件格式和约定
6 游戏和屏保
7 杂项
8 系统管理命令和守护进程

(讲真我也记不住。。。)

所以我一般这样使用man:

man -k zip # 在手册中查询命令zip

bzcmp(1), bzdiff(1)      - compare bzip2 compressed files
bzip2(1), bunzip2(1)     - a block-sorting file compressor, v1.0.6 bzcat - decompresses files to stdout bzip2recover - recovers data from damaged bzip2 files
bzmore(1), bzless(1)     - file perusal filter for crt viewing of bzip2 compressed text
funzip(1)                - filter for extracting from a ZIP archive in a pipe
gzip(1)                  - compression/decompression tool using Lempel-Ziv coding (LZ77)
unzip(1)                 - list, test and extract compressed files in a ZIP archive
unzipsfx(1)              - self-extracting stub for prepending to ZIP archives
zforce(1)                - force gzip files to have a.gz suffix
zip(1)                   - package and compress (archive) files
zip(n)                   - Data compression "zip"
zipcloak(1)              - encrypt entries in a zipfile
zipdetails(1)            - display the internal structure of zip files
zipgrep(1)               - search files in a ZIP archive for lines matching a pattern
zipinfo(1)               - list detailed information about a ZIP archive
zipnote(1)               - write the comments in zipfile to stdout, edit comments and rename files in zipfile
zipsplit(1)              - split a zipfile into smaller zipfiles
znew(1)                  - convert compressed files to gzipped files
(END)

# 可以辨认出我们需要的是1区段的手册信息,因此
man 1 zip

ZIP(1L)                                                                                                                                                  ZIP(1L)



NAME
       zip - package and compress (archive) files

SYNOPSIS
       zip [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [--longoption ...]  [-b path] [-n suffixes] [-t date] [-tt date] [zipfile [file ...]]  [-xi list]

       zipcloak (see separate man page)

       zipnote (see separate man page)

       zipsplit (see separate man page)

       Note:   Command line processing in zip has been changed to support long options and handle all options and arguments more consistently.  Some old command
       lines that depend on command line inconsistencies may no longer work.

DESCRIPTION
       zip is a compression and file packaging utility for Unix, VMS, MSDOS, OS/2, Windows 9x/NT/XP, Minix, Atari, Macintosh, Amiga, and Acorn RISC OS.   It  is
       analogous to a combination of the Unix commands tar(1) and compress(1) and is compatible with PKZIP (Phil Katz's ZIP for MSDOS systems).
...

man page一般分为如下几部分

NAME(名称)
该命令或函数的名称,接着是一行简介。
SYNOPSIS(概要)
对于命令,正式的描述它如何运行,以及需要什么样的命令行参数。对于函数,介绍函数所需的参数,以及哪个头文件包含该函数的定义。
DESCRIPTION(说明)
命令或函数功能的文本描述。
EXAMPLES(示例)
常用的一些示例。
SEA ALSO(参见)
相关命令或函数的列表。

也可能存在其他部分内容,但这些部分没有得到跨手册页的标准化。常见的例子包括:OPTIONS(选项),EXIT STATUS(退出状态),ENVIRONMENT(环境),BUGS(程序漏洞),FILES(文件),AUTHOR(作者),REPORTING BUGS(已知漏洞),HISTORY(历史)和COPYRIGHT(版权)。

man 会使用 less程序打开相关的页面,在less中输入h就可以打开帮助页面。less的操作与vi有一定的相似性,常用操作有:

q - 退出
d - 下翻半屏
u - 上翻半屏
/ - 搜索

使用感受

其实命令行这玩意如果配置好补全,然后熟悉常用命令后,用起来是非常顺畅舒服的。Ubuntu等发行版的存在拉低了Linux系对用户的要求,但是想要真正的能“正常使用”Linux(比如你的ubuntu莫名其妙开不了机你又不想重装系统的时候)。而对于mac,如果你跟我一样属于软件洁癖不想装一堆扩展功能性的软件,还是好好用一下命令行吧。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Ubuntu的发音 Ubuntu,源于非洲祖鲁人和科萨人的语言,发作 oo-boon-too 的音。了解发音是有意...
    萤火虫de梦阅读 99,552评论 9 467
  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 12,218评论 2 33
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,904评论 18 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,204评论 25 708
  • 1.太近了,怕你煩膩 太遠了,怕與你生疏 這就是,我眼中的我們 2.昨天,和我牽手的是你 昨夜,夢里牽...
    王子小白阅读 93评论 0 1