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)
问题描述
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屋!