免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2280 | 回复: 4
打印 上一主题 下一主题

如何截出微秒时间? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-09-18 12:20 |只看该作者 |倒序浏览
file.log
2011-09-18 00:00:01,102
2011-09-18 00:00:01,397
2011-09-18 00:00:01,452
2011-09-18 00:00:01,970
2011-09-18 00:00:02,036
2011-09-18 00:00:02,289
2011-09-18 00:00:02,344
2011-09-18 00:00:02,538
2011-09-18 00:00:02,591
2011-09-18 00:00:02,977
2011-09-18 00:00:02,997
2011-09-18 00:00:03,072
2011-09-18 00:00:03,168
2011-09-18 00:00:03,200
2011-09-18 00:00:03,270
2011-09-18 00:00:03,348
2011-09-18 00:00:03,489
2011-09-18 00:00:03,535
2011-09-18 00:00:03,816
2011-09-18 00:00:03,841
2011-09-18 00:00:04,016
2011-09-18 00:00:04,109
2011-09-18 00:00:04,462
2011-09-18 00:00:04,679
2011-09-18 00:00:04,942
2011-09-18 00:00:04,969
2011-09-18 00:00:05,088
2011-09-18 00:00:05,543
2011-09-18 00:00:05,643
2011-09-18 00:00:05,653
2011-09-18 00:00:05,972
2011-09-18 00:00:05,993
2011-09-18 00:00:06,162
2011-09-18 00:00:06,206
2011-09-18 00:00:06,401
2011-09-18 00:00:06,418
2011-09-18 00:00:06,616
2011-09-18 00:00:06,990
2011-09-18 00:00:07,143
2011-09-18 00:00:07,172
2011-09-18 00:00:07,177

比如截出2011-09-18 00:00:04到2011-09-18 00:00:07之间的
sed -n "/2011-09-18 00:00:04/,/2011-09-18 00:00:07/p" file

开始时间是正确的,结束时间是2011-09-18 00:00:07,143就不对了,需要得到2011-09-18 00:00:07,177

论坛徽章:
1
摩羯座
日期:2014-12-29 15:59:36
2 [报告]
发表于 2011-09-18 12:36 |只看该作者
sed -n "/2011-09-18 00:00:04/,/2011-09-18 00:00:08/{/:08,/d;p}" file

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
3 [报告]
发表于 2011-09-18 12:48 |只看该作者
  1. sed -n "/2011-09-18 00:00:04/,/2011-09-18 00:00:08/p" urfile | head -n -1
复制代码

论坛徽章:
2
射手座
日期:2014-10-10 15:59:4715-16赛季CBA联赛之上海
日期:2016-03-03 10:27:14
4 [报告]
发表于 2011-09-18 12:53 |只看该作者
  1. grep "2011-09-18 00:00:0[4-7].*" file
复制代码

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
5 [报告]
发表于 2011-09-18 13:02 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP