awk-打印包含在初始分析中找到的最大值的所有行(行之间包含U + 2500 Unicode字符) [英] awk - Print all lines containing the Max value found in the initial analysis (Containing U+2500 Unicode Character between the lines)

查看:37
本文介绍了awk-打印包含在初始分析中找到的最大值的所有行(行之间包含U + 2500 Unicode字符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在这里得到回答的问题

I have an issue that was answered here awk - Print all lines containing the Max value found in the initial analysis, but that now needs to be adapted to work when there is U+2500 unicode character between the lines.

问题如下,我有一个新的条目文件,如下:

The problem is as follows below, I have a new entry file as below:

0.0008    6
────────────
9.0    10
────────────
9.0    19
────────────
0.7    33

如果我尝试使用

If I try to find the maximum value using the answers to awk - Print all lines containing the Max value found in the initial analysis, the output is always being as shown below:

──────
──────
──────

这不是预期的出口,但是我应该得到类似的东西:

This is not the expected exit, But I should get something like:

9.0    10
9.0    19

注意: 创建此问题是为了不影响标记为已解决"的解决方案的选择.在 awk-打印包含在初始分析中找到的最大值的所有行.

推荐答案

您也可以使用这2个pass awk:

You may use this 2 pass awk as well:

awk '$1+0 != $1 {next} FNR==NR {if (max < $1) max=$1; next} $1 == max' file{,}

9.0    10
9.0    19

我们在第一阶段计算最大值,而忽略 $ 1 是非数字的所有行,然后在第二阶段打印所有具有 $ 1 max相同的记录值.

We compute max in first phase and ignore all lines where $1 is non-numeric, then in 2nd phase print all records that have $1 same as max value.

这篇关于awk-打印包含在初始分析中找到的最大值的所有行(行之间包含U + 2500 Unicode字符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆