鱼C论坛

 找回密码
 立即注册
查看: 670|回复: 0

[学习笔记] linux查看命令利器-tldr

[复制链接]
发表于 2023-3-10 09:18:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
tldr:too long don't read的简称,相比man help只显示常用命令的用法,且比较简明易懂

安装可用npm pip等,例如:pip install tldr

安装后可sudo tldr -u

比如要查awk常用命令,使用效果如下(该演示是linux环境,windows也可以安装)
  1. www-data@rjyby07:~$ tldr awk
  2. # awk                                                                                                                                                   
  3.                                                                                                                                                          
  4.   A versatile programming language for working on files.                                                                                                
  5.   More information: <https://github.com/onetrueawk/awk>.                                                                                                
  6.                                                                                                                                                          
  7. - Print the fifth column (a.k.a. field) in a space-separated file:                                                                                       
  8.                                                                                                                                                          
  9.   awk '{print $5}' path/to/file                                                                                                                          
  10.                                                                                                                                                          
  11. - Print the second column of the lines containing "foo" in a space-separated file:                                                                       
  12.                                                                                                                                                          
  13.   awk '/foo/ {print $2}' path/to/file                                                                                                                    
  14.                                                                                                                                                          
  15. - Print the last column of each line in a file, using a comma (instead of space) as a field separator:                                                   
  16.                                                                                                                                                          
  17.   awk -F ',' '{print $NF}' path/to/file                                                                                                                  
  18.                                                                                                                                                          
  19. - Sum the values in the first column of a file and print the total:                                                                                      
  20.                                                                                                                                                          
  21.   awk '{s+=$1} END {print s}' path/to/file                                                                                                               
  22.                                                                                                                                                          
  23. - Print every third line starting from the first line:                                                                                                   
  24.                                                                                                                                                          
  25.   awk 'NR%3==1' path/to/file                                                                                                                             
  26.                                                                                                                                                          
  27. - Print different values based on conditions:                                                                                                            
  28.                                                                                                                                                          
  29.   awk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}' path/to/file                        
  30.                                                                                                                                                          
  31. - Print all lines where the 10th column value equals the specified value:                                                                                
  32.                                                                                                                                                          
  33.   awk '($10 == value)'                                                                                                                                   
  34.                                                                                                                                                          
  35. - Print all the lines which the 10th column value is between a min and a max:                                                                           
  36.                                                                                                                                                          
  37.   awk '($10 >= min_value && $10 <= max_value)'
复制代码



想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-19 02:34

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表