一、引言
Linux的伟大成功一个重要的原因就是有各种各样的小工具,比如ls
, du
、top
、du
等,可以完成Linux操作系统的各种文件操作、目录操作以及系统管理等,但是
,以下几个因素也会成为我们习惯命令行操作的拦路虎:
- 可是使用的命令行工具太多了。
- 命令行接口(选项)太多了。
当安装这些小工具不是问题的时候,使用这些小工具就成为最大的问题了,首当其冲就是了解命令行的使用说明,最直接的肯定是 man
工具, 如下图,我们可以在命令行下输入man man
就可以其实获得关于man的使用说明。
图一: man使用说明
当然很多程序, 可以通过直接执行命令行工具本身, 比如samtools
或者 bedtools --help
获取帮助信息。
不过今天介绍是一个小工具tldr()
。
二、TLDR介绍
tldr-pages
采用一种社区驱动模式, Github仓库地址: https://github.com/tldr-pages/tldr, Web 客户端: https://tldr.ostera.io/。
Linux命令行工具运行命令如下:
图二: tldr使用模式
相对于man页面,tldr具有更多的例子。
三、安装
tldr 提供了各种语言的客户端: 下面列出几种比较常用的安装模式:
Node.js 客户端(需要先安装 Node.js) :
npm install -g tldr
Python 客户端
pip install tldr
GO 客户端:
wget https://github.com/pranavraja/tldr/releases/download/v1/tldr_linux_amd64.tar.gz
tar xzvf tldr_linux_amd64.tar.gz
mv tldr_linux_amd64 tldr-1.0
export PATH=$PATH:$PWD/tldr-1.0
四、使用
命令行接口(以Node.js客户端为例):
$ tldr
Usage: tldr command [options]
Simplified and community-driven man pages
Options:
-h, --help output usage information
-V, --version output the version number
-l, --list List all commands for the chosen platform in the cache
-a, --list-all List all commands in the cache
-1, --single-column List single command per line (use with options -l or -a)
-r, --random Show a random command
-e, --random-example Show a random example
-f, --render [file] Render a specific markdown [file]
-m, --markdown Output in markdown format
-o, --os [type] Override the operating system [linux, osx, sunos]
--linux Override the operating system with Linux
--osx Override the operating system with OSX
--sunos Override the operating system with SunOS
-t, --theme [theme] Color theme (simple, base16, ocean)
-s, --search [keywords] Search pages using keywords
-u, --update Update the local cache
-c, --clear-cache Clear the local cache
Examples
$ tldr tar
$ tldr du --os=linux
$ tldr --search "create symbolic link to file"
$ tldr --list
$ tldr --list-all
$ tldr --random
$ tldr --random-example
To control the cache
$ tldr --update
$ tldr --clear-cache
To render a local file (for testing)
$ tldr --render /path/to/file.md
下面介绍几种功能性可选项:
-l: 列出缓存中指定操作系统的所有命令;
-a: 列出缓存中所有命令;
-m: 输出格式为markdown 格式;
--linux/--osx/--sunos:重载操作系统类型
-t: 颜色主题模式;
-u: 升级本地缓存;
-c:清除本地缓存;
示例:
$ tldr tar
tar
Archiving utility.
Often combined with a compression method, such as gzip or bzip.
- Create an archive from files:
tar cf target.tar file1 file2 file3
- Create a gzipped archive:
tar czf target.tar.gz file1 file2 file3
- Extract an archive in a target folder:
tar xf source.tar -C folder
- Extract a gzipped archive in the current directory:
tar xzf source.tar.gz
- Extract a bzipped archive in the current directory:
tar xjf source.tar.bz2
- Create a compressed archive, using archive suffix to determine the compression program:
tar caf target.tar.xz file1 file2 file3
- List the contents of a tar file:
tar tvf source.tar
很方便的一个小工具,如果忘记一个命令具体使用,请使用:tldr command
所支持的不同平台的命令行使用用例,请下载:
本文材料为 BASE (Biostack Applied bioinformatic SEies ) 课程 Linux Command Line Tools for Life Scientists 材料, 版权归 上海逻捷信息科技有限公司 所有。
Last Update: 2017/11/27 21:34