Link

一个好用的’精简版’Man

目录

  1. 一个好用的’精简版’Man
  2. TLDR

TLDR

Linux 下如果不知道某个命令怎么用,一般要么 <Command-line> --help ,要么 man <command-line>,但是这两种更多的是关于命令参数的说明,通常我们只需要知道命令怎么用,有示例即可。

于是有了 TLDR(Too Long,Didn’t Read),只展示命令的常见用法。

macOS 下安装:

brew install tldr

更新 tldr 缓存:

tldr -u

开用:

$ tldr cp

cp

Copy files and directories.

- Copy a file to another location:
    cp path/to/file.ext path/to/copy.ext

- Copy a file into another directory, keeping the filename:
    cp path/to/file.ext path/to/target_parent_directory

- Recursively copy a directory's contents to another location (if the destination exists, the directory is copied inside it):
    cp -r path/to/directory path/to/copy

- Copy a directory recursively, in verbose mode (shows files as they are copied):
    cp -vr path/to/directory path/to/copy

- Copy text files to another location, in interactive mode (prompts user before overwriting):
    cp -i *.txt path/to/target_directory

- Dereference symbolic links before copying:
    cp -L link path/to/copy
    
    
$ tldr sed

sed

Edit text in a scriptable manner.

- Replace the first occurrence of a string in a file, and print the result:
    sed 's/find/replace/' filename

- Replace all occurrences of an extended regular expression in a file:
    sed -E 's/regex/replace/g' filename

- Replace all occurrences of a string in a file, overwriting the file (i.e. in-place):
    sed --in-place='' 's/find/replace/g' filename

- Replace only on lines matching the line pattern:
    sed '/line_pattern/s/find/replace/' filename

- Print only text between n-th line till the next empty line:
    sed -n 'line_number,/^$/p' filename

- Apply multiple find-replace expressions to a file:
    sed -e 's/find/replace/' -e 's/find/replace/' filename

- Replace separator / by any other character not used in the find or replace patterns, e.g., #:
    sed 's#find#replace#' filename

真好用!