任务:report.txt文件里有以下内容:记录了一些方法的执行时间,要求按执行时间降序排列.

 void com.dustpan.zeus.core.service.MergeService.startService(int)|2
void com.dustpan.zeus.core.service.InitShopDateService.startService(int)|1
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|475
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|96
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|1013
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|184
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|729
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|14
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|394
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|90
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|569
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|796
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|1648
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|82
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|1018
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|14
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|937
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|17
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|601
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|52
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|5081
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|388
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|198
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|11
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|203
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|11
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|241
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|13
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|176
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|12
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|206
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|33
boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|242
boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|19

report.txt

linux命令方法:sort -run -k 2 -t '|' report.txt
 原理:sort linux下的排序工具,参数解释:
  -r  降序排列
  -u  去重
  -n  以数字大小排序(默认是首字母排序)
  -t  指定分隔符 这里我们指定'|'为分隔符
  -k  指定分隔后的第几位进行排序 这里我们指定第2位

使用linux sort给一个文件里的内容按规则排序的更多相关文章

  1. linux怎么模糊查找一个文件

    linux如何模糊查找一个文件 在当前目录下搜索指定文件: find . -name test.txt 在当前目录下模糊搜索文件: find . -name '*.txt' 在当前目录下搜索特定属性的 ...

  2. shell统计一个文件里某行出现的次数并排序

    话说有个aaa.txt文件,文件内容如下: aaaabbbbccccddddeeeeffffmmmmooooaaaaccccaaaabbbbddddaaaammmmbbbbaaaaoooo 然后面试题 ...

  3. linux 如何显示一个文件的某几行(中间几行)

    linux 如何显示一个文件的某几行(中间几行) [一]从第3000行开始,显示1000行.即显示3000~3999行 cat filename | tail -n +3000 | head -n 1 ...

  4. 【转载】在Linux下,一个文件也有三种时间,分别是:访问时间、修改时间、状态改动时间

    在windows下,一个文件有:创建时间.修改时间.访问时间.而在Linux下,一个文件也有三种时间,分别是:访问时间.修改时间.状态改动时间. 两者有此不同,在Linux下没有创建时间的概念,也就是 ...

  5. Linux中一个文件10行内容,如何输出5-8内容到屏幕

    题目是这样的,Linux中一个文件10行内容,如何输出5-8内容到屏幕首先我们模拟一下这样的环境: [root@localhost question]# pwd /root/question [roo ...

  6. Windows cmd 将命令(/指令)写到一个文件里,直接运行这个文件。提高工作效率

    Windows cmd 批处理(cmd/bat)文件的简单使用介绍 前言 如果你想我一样,要每天都需要在cmd上,用键盘去敲击相同的命令,时间一长,你就觉得很无聊.有没有什么比较高效的方法,让我们不用 ...

  7. Linux 如何查看一个文件夹下面有多少个文件

    Linux 如何查看一个文件夹下面有多少个文件 $ tree $ find ./ -type f | wc -l $ ls -l | grep "^-" | wc -l refs ...

  8. java中的文件读取和文件写出:如何从一个文件中获取内容以及如何向一个文件中写入内容

    import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.Fi ...

  9. Flex读取txt文件里的内容(二)

    Flex读取txt文件里的内容 自己主动生成的文件 LoadTxt-app.xml: <?xml version="1.0" encoding="utf-8&quo ...

随机推荐

  1. 文件查找---find

    文件查找(find) 1 find 简单的说,就是实时查找指定的内容或条件.特点:最新.最快.最准确. 用法:find [查找路径] [查找条件] [找到后进行的动作]     eg. find /e ...

  2. 学习笔记:javascript 表单对象(form)

    Form 对象属性 属性 描述 acceptCharset 服务器可接受的字符集. action 设置或返回表单的 action 属性. enctype 设置或返回表单用来编码内容的 MIME 类型. ...

  3. [刷题]算法竞赛入门经典 3-4/UVa455 3-5/UVa227 3-6/UVa232

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 题目:算法竞赛入门经典 3-4/UVa455:Periodic Strings 代码: //UVa455 #inclu ...

  4. Trie树详解

    1. 概述 Trie树,又称字典树,单词查找树或者前缀树,是一种用于快速检索的多叉树结构,如英文字母的字典树是一个26叉树,数字的字典树是一个10叉树.Trie一词来自retrieve,发音为/tri ...

  5. JEESZ分布式框架简介

    声明:该框架面向企业,是大型互联网分布式企业架构,后期会介绍Linux上部署高可用集群项目. 项目基础功能截图(自提供了最小部分) 介绍 1.      项目核心代码结构截图 <modules& ...

  6. CentOS-Zabbix-agent客户端的编译安装

    系统环境: CentOS 6.7 官网下载安装包:http://www.zabbix.com/download 本文用的是Zabbix 3.0 LTS 上传至客户端服务器并解压 .tar.gz 进入解 ...

  7. 导出CSV,导出excel数字过长显示科学计数法解决方案

    再导出CSV表格时发现数字超过一定长度后会缩写成科学计数法,对于手机号和身份证就比较尴尬了. 在网上找了一下,大部分都是加"'"将数字转换为字符串,但是纠结于导出的数字前面有个单引 ...

  8. redis入门指南-附录B

  9. SimpleDateFormat使用和线程安全问题

    SimpleDateFormat 是一个以国别敏感的方式格式化和分析数据的具体类. 它允许格式化 (date -> text).语法分析 (text -> date)和标准化. Simpl ...

  10. 005---query接口初步

    Query session.createQuery(String hql)方法; * hibernate的session.createQuery()方法是使用HQL(hibernate的查询语句)语句 ...