美文网首页
A piece of CMD

A piece of CMD

作者: 谭雅翔 | 来源:发表于2016-12-03 11:51 被阅读25次

    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,如果你跟我一样属于软件洁癖不想装一堆扩展功能性的软件,还是好好用一下命令行吧。

    相关文章

      网友评论

          本文标题:A piece of CMD

          本文链接:https://www.haomeiwen.com/subject/juqcmttx.html