一、awk
# 统计 a-read-file 接口 中,接口耗时 超过 0.007 秒的有多少个请求
D@Demon ~]awk′awk′7>0.007' acc.log | wc -l (-l 表示统计有多少行)
404
二、head
1、head 命令参数
-n 指定获取多少行
-v 输出显示文件的文件名
-c 按指定字节显示
-q 隐藏文件名
2、head 使用
# 获取前 3 条日志
[D@Demon ~]$ head -n 3 acc.log
2014-07-17
16:40:13 14477 127.0.0.1 4FCD5690BB5FF879 m-create-file 0.022945 0 ax_add_file:0.003,mx_add_part:0.015,mx_create:0.002 fid:19-1405586413 res:ax_add_file.19- 405586413,mx_add_part.19-1405586413.0,1.mx_create.19-1405586413-0.0.8388608
2014-07-17
16:40:13 14477 127.0.0.1 72CA0245933664A5 m-info-file 0.004441 0 mx_get_file:0.004 fid:19-1405586413 res:mx_get_file.19-1405586413
2014-07-17
16:40:13 14478 127.0.0.1 461BE11327FCDCD9 m-close-file 0.019908 0 ax_put:0.001,ax_add_blk:0.012,aesenc:0.000,ax_get_blk:0.001,mx_get_file:0.003,use_sha1ctx:0.000,size:0.000 fdid:10,nmid:1885573511091757896,fid:19-1405586413 res:ax_add_blk.da39a3ee5e6b4b0d3255bfef95601890afd80709,1.ax_put.da39a3ee5e6b4b0d3255bfef95601890afd80709.0.0,ax_get_blk.da39a3ee5e6b4b0d3255bfef95601890afd80709,mx_get_file.19-1405586413
三、tail
# 获取后 3 条日志
[D@Demon ~]$ tail -3 acc.log
2014-07-17
16:56:20 14478 127.0.0.1 E77A964E4722E34A m-write-file 0.017384 0 mx_get_part:0.001,mx_update_part_sha1:0.012,aesenc:0.000,nparts:0.000,sha:0.000,mx_write:0.000,mx_get_file:0.003,assureblks:0.000,rpost:0.000 hash:6563625978a161165d3c9c29a08e1e35060e54ba,pos:0,fid:52-1405587380,size:4096 res:mx_get_part.52-1405587380.0,mx_get_file.52-1405587380,mx_update_part_sha1.52-1405587380.0.-1,1.mx_write.52-1405587380-0.0.4096
2014-07-17
16:56:20 14477 127.0.0.1 B8D40F03481F9881 m-write-file 0.017265 0 x_get_part:0.001,mx_update_part_sha1:0.012,aesenc:0.000,nparts:0.000,sha1ctx:0.000,sha:0.000,mx_write:0.000,mx_get_file:0.003,assureblks:0.000,rpost:0.000 hash:cfa211339753f9e6af4b9a35224be776a0f97b07,pos:0,fid:52-1405587380,size:4096 res:mx_get_part.52-1405587380.0,mx_get_file.52-1405587380,mx_update_part_sha1.52-1405587380.0.4096,1.mx_write.52-1405587380-0.0.4096
2014-07-17
16:56:20 14478 127.0.0.1 AB214643262BAE4E m-write-file 0.018161 0 mx_get_part:0.001,mx_update_part_sha1:0.012,aesenc:0.000,nparts:0.000,sha:0.000,mx_write:0.000,mx_get_file:0.003,assureblks:0.000,rpost:0.000 hash:972a2132d806708d586540b4822681ec43188148,pos:0,fid:52-1405587380,size:4096 res:mx_get_part.52-1405587380.0,mx_get_file.52-1405587380,mx_update_part_sha1.52-1405587380.0.-1,1.mx_write.52-1405587380-0.0.4096
四、wc
1、wc 命令参数:
-l 统计行数
-c 统计字节数
-w 统计字数
2、统计 acc.log 有多少行
[D@Demon ~]$ wc -l acc.log
1000 acc.log