Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 命令行上日志文件中时间的分块直方图_Linux_Command Line_Histogram_Binning - Fatal编程技术网

Linux 命令行上日志文件中时间的分块直方图

Linux 命令行上日志文件中时间的分块直方图,linux,command-line,histogram,binning,Linux,Command Line,Histogram,Binning,为了快速评估linux服务器上日志文件中各种操作的计时,我想从日志中提取它们,并创建一个文本/tsv样式的直方图。为了更好地了解计时是如何分布的,我想将它们划分为0-10ms、10-20ms等范围 输出应如下所示: 121 10 39 20 12 30 7 40 1 100 如何使用常用的unix命令行工具集实现这一点?快速回答: cat <file> | egrep -o [0-9]+ | sed "s/$/ \/10*10/" | bc

为了快速评估linux服务器上日志文件中各种操作的计时,我想从日志中提取它们,并创建一个文本/tsv样式的直方图。为了更好地了解计时是如何分布的,我想将它们划分为0-10ms、10-20ms等范围

输出应如下所示:

121    10
 39    20
 12    30
  7    40
  1   100
如何使用常用的unix命令行工具集实现这一点?

快速回答:

cat <file> | egrep -o [0-9]+ | sed "s/$/ \/10*10/" | bc | sort -n | uniq -c
cat|egrep-o[0-9]+|sed“s/$/\/10*10/”| bc | sort-n | uniq-c
详细答复:

  • 格雷普你的时间或数字模式。您可能需要执行多个grep步骤才能从日志中准确提取所需的数字

  • 使用sed将整数除以所需因子的算术表达式相加,然后再将其相乘

  • bc执行计算

  • 著名的sort | uniq组合用于计数事件