1. 安装tldr
macOS
brew install tldr
Ubuntu
apt install tldr
CentOS
yum install tldr
2. 使用帮助
由于目前的主力生产设备是MacBook Pro,因此以下所有的测试都是针对macOS,与其他OS可能有所不同,望周知。
$ tldr -h
usage: tldr [-v] [OPTION]... SEARCH
available commands:
-v print verbose output
--version print version and exit
-h, --help print this help and exit
-u, --update update local database
-c, --clear-cache clear local database
-l, --list list all entries in the local database
-p, --platform=PLATFORM select platform, supported are linux / osx / sunos / windows / common
--linux show command page for Linux
--osx show command page for OSX
--sunos show command page for SunOS
-r, --render=PATH render a local page for testing purposes
3. 更新缓存
tldr --update 或 tldr -u
如果想要清除缓存
tldr --clear-cache 或 tldr -c
3. 使用帮助
如果想要获取命令的使用方法,可以使用tldr 命令
的格式,如:
$ tldr sed
sed
Edit text in a scriptable manner.
More information: <https://ss64.com/osx/sed.html>.
- 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/regular_expression/replace/g' filename
- Replace all occurrences of a string [i]n a file, overwriting the file (i.e. in-place):
sed -i '' '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
- [d]elete the line at the specific line number [i]n a file, overwriting the file:
sed -i '' 'line_numberd' filename
由于sed 命令的特殊性,以上操作是针对Linux OS的使用方法,如果限定macOS,可以使用tldr sed -p osx
或者 tldr sed --osx
(仅macOS生效):
$ tldr sed -p osx
sed
Edit text in a scriptable manner.
More information: <https://ss64.com/osx/sed.html>.
- 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/regular_expression/replace/g' filename
- Replace all occurrences of a string [i]n a file, overwriting the file (i.e. in-place):
sed -i '' '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
- [d]elete the line at the specific line number [i]n a file, overwriting the file:
sed -i '' 'line_numberd' filename