eg: cut -d' ' -f1 ~/.bash_history|sort -d |uniq -c|sort -nr | head
功能: 统计最常用的十条历史命令及其使用次数
cut -d' ' -f1 ~/.bash_history
从 ~/.bash_history 文件中以空格为分割符( -d' ')剪出第一列。
f1 指第一列, f2 指第二列 .....
f1,3 指 第一列和第三列, f1-3 指第一列到第三列
sort -d
按字典需排序 -d
uniq -c
去重并统计次数 -c uniq 只能针对连续的多行进行去重,故经常与排序 sort 一起使用。
sort -nr
按数字排序 -n 并按降序 -r 默认是升序
head
输出显示文件前面部分的内容,默认显示10行。
功能: 统计最常用的十条历史命令及其使用次数
cut -d' ' -f1 ~/.bash_history
从 ~/.bash_history 文件中以空格为分割符( -d' ')剪出第一列。
f1 指第一列, f2 指第二列 .....
f1,3 指 第一列和第三列, f1-3 指第一列到第三列
sort -d
按字典需排序 -d
uniq -c
去重并统计次数 -c uniq 只能针对连续的多行进行去重,故经常与排序 sort 一起使用。
sort -nr
按数字排序 -n 并按降序 -r 默认是升序
head
输出显示文件前面部分的内容,默认显示10行。