Skip to main content
added 165 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k
awk 'NR == 6 { vfe = $4 } NR > 6 && $1 > vfe && $2 > 0 { print vfe, $1; exit }' file 

For the given input data in file this will produce

1.95329810 4.152 

The awk script ignores the first five lines of input. At line six, it picks out the fourth field an assigns it to the variable vfe (short ofr "Fermi energy".

The code then assumes that the values in column one are increasing, and when the first of these first column values reaches a value above the value stored in vfe, and if the second column is non-zero, it prints out vfe and the value from the first column and exits.

Unfortunately, I don't fully understand your longer code segment as there is no explanation of what you actually want it to do.

awk 'NR == 6 { v = $4 } NR > 6 && $1 > v && $2 > 0 { print v, $1; exit }' file 

For the given input data in file this will produce

1.95329810 4.152 

The awk script ignores the first five lines of input. At line six, it picks out the fourth field an assigns it to the variable v.

The code then assumes that the values in column one are increasing, and when the first of these first column values reaches a value above the value stored in v, and if the second column is non-zero, it prints out v and the value from the first column and exits.

awk 'NR == 6 { fe = $4 } NR > 6 && $1 > fe && $2 > 0 { print fe, $1; exit }' file 

For the given input data in file this will produce

1.95329810 4.152 

The awk script ignores the first five lines of input. At line six, it picks out the fourth field an assigns it to the variable fe (short ofr "Fermi energy".

The code then assumes that the values in column one are increasing, and when the first of these first column values reaches a value above the value stored in fe, and if the second column is non-zero, it prints out fe and the value from the first column and exits.

Unfortunately, I don't fully understand your longer code segment as there is no explanation of what you actually want it to do.

Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k

awk 'NR == 6 { v = $4 } NR > 6 && $1 > v && $2 > 0 { print v, $1; exit }' file 

For the given input data in file this will produce

1.95329810 4.152 

The awk script ignores the first five lines of input. At line six, it picks out the fourth field an assigns it to the variable v.

The code then assumes that the values in column one are increasing, and when the first of these first column values reaches a value above the value stored in v, and if the second column is non-zero, it prints out v and the value from the first column and exits.