常用命令收集

引入一个更为专业的命令收集站点 : https://www.commandlinefu.com/commands/browse 统计第一列相同,第二列平均值 1 cat xxx |awk '{a[$1]+=$2;c[$1]++}END{l=asorti(a,b);for(i=1;i<=l;i++)print b[i],a[b[i]]/c[b[i]]}' 时间段统计日志: 1 2 sed -n '/2018:02:30/,/2018:03:00/p' www.log |awk '{a[$1]+=1;} END {for(i in a){print a[i]" "i;}}' |sort -t " " -k 1 -n sed -n '/2018:01:50/,/2018:02:00/p' www.log

Shellscript相关

1. shell 脚本执行的几种方法 bash(sh) /path/script.sh 赋予执行权限 /path/script.sh 或 ./scripts.sh source script.sh 或 . script.sh 在此方法中执行,子 shell 中定义的变量,可在父 shell 中调用(其他方式父 shell 不能直接调用子 shell 的变量)

那些好用的工具收集

1. 文件内容搜索工具(ag) 1 2 3 # 类似于grep [root@01 ~]# yum install the_silver_searcher [root@01 ~]# ag "hello" ./example 2. mysql 命令补全工具,可替代mysql命令 https://github.com/dbcli 1 2 [root@01 ~]# pip install -U mycli [root@01 ~]# mycli 3. 多线程下