I wanted to know if there is a way to modify this awk statement to find out when column two switches directions. What i mean is the number in column two will get bigger then start to get smaller. When this happens I want to print out the value of column one.
Niether of them worked; the problem was it seemed to pick random points not the peaks (I plotted them using GMT).
Instead of accepting defeat can I trouble you for a little explanation, if I understood the logic a little better I think I could tweak it. I am still new at awk but my professor loves it, and the more I use it the more I realize how powerful it actually is.
This is the part I don't quite understand. What exactly does NR == 1 accomplish? Your setting the number of rows equal to one? does a ';' seperate commands? So you set last equal to column 2, lost_row equal to column one.
Why do your run a getline? I looked it up and it is defined as:
getline - returns 1 if it finds a record, and 0 if the end of the file is encountered
Anyways I get the feeling that $1 and $2 are now rows above and below not columns?
Some special variables that AWK sets for each record (usually a line) that it reads:
NR = record number (by default the record separator, RS, is a newline, so NR is often the current line number). NR==1 {...} means to execute the commands in braces if this is the first record that AWK is processing.
NF = after field splitting, the number of fields (columns) in the current record.
I need to specify that location make sense? there is a numeric value one row above (NR-1) and in field 2 (which I abbreviated as [NR-1,$2] ) that I want to compare to the current row NR and field 2 (abbreviated $2).