0

Input:

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 

Output:

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* 
0

1 Answer 1

3
$ 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* 

This initializes the smallest found value, min, to the first value in the last column if we're currently reading the first line (NR == 1). Then, for each input line, if the value in the last column is strictly smaller than our min value, the min value is replaced and the current line gets a * appended.

Every line is then unconditionally outputted.

1
  • A NR == 1 { min = $NF; next } might avoid the strictly smaller test. Commented May 16, 2021 at 21:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.