前のすべての数字より小さい最後の列のすべての数字を強調表示します。

前のすべての数字より小さい最後の列のすべての数字を強調表示します。

入力する:

network-snapshot-000000        time 6m 40s       fid50k_full 34.9546
network-snapshot-000201        time 6m 52s       fid50k_full 30.8073
network-snapshot-000403        time 6m 51s       fid50k_full 33.3470
network-snapshot-000604        time 6m 51s       fid50k_full 32.7172
network-snapshot-000806        time 6m 49s       fid50k_full 30.3764

出力:

network-snapshot-000000        time 6m 40s       fid50k_full 34.9546
network-snapshot-000201        time 6m 52s       fid50k_full 30.8073*
network-snapshot-000403        time 6m 51s       fid50k_full 33.3470
network-snapshot-000604        time 6m 51s       fid50k_full 32.7172
network-snapshot-000806        time 6m 49s       fid50k_full 30.3764*

ベストアンサー1

$ awk 'NR == 1 { min = $NF } ($NF < min) { min = $NF; $0 = $0 "*" }; 1' file
network-snapshot-000000        time 6m 40s       fid50k_full 34.9546
network-snapshot-000201        time 6m 52s       fid50k_full 30.8073*
network-snapshot-000403        time 6m 51s       fid50k_full 33.3470
network-snapshot-000604        time 6m 51s       fid50k_full 32.7172
network-snapshot-000806        time 6m 49s       fid50k_full 30.3764*

min現在最初の行(NR == 1)を読み取っている場合は、見つかった最小値を最後の列の最初の値に初期化します。その後、各入力行について、最後の列の値が私たちのmin値より厳密に小さい場合、そのmin値が置き換えられ、現在の行が追加されます*

その後、無条件に各行を出力します。

おすすめ記事