- Code: Select all
-89.977365 30.258552
-89.977512 30.258625
-89.978026 30.258699
-89.978392 30.258992
-89.979052 30.259065
The columns are separated by tabs, and each ends with a newline.
What I want to do is reorder them in reverse. For example, the 5 pairs above would end up as:
- Code: Select all
-89.979052 30.259065
-89.978392 30.258992
-89.978026 30.258699
-89.977512 30.258625
-89.977365 30.258552
I absolutely do not want them in numerical order (even though this particular example happens to be in numerical order). These are longitudes and latitudes describing the coast of Louisiana, and the order in which each point is drawn is important. The coast is broken up into a bunch of segments, and the drawing has to be continuous from segment to segment. So, if one segment is moving in one direction, and another is moving the opposite way, there will be a huge linear jump as it goes from the last point of segment a to the last point of segment b.
Does that make any sense?
All I want is a quick and dirty routine that will flip a simple 2-column table upside down. I tried piping from awk to sort, but sort tries to compare the numbers, which is no good. I can't find an awk method for this. And I can't find a Perl method either, although I might not notice a good Perl script if I saw one.
I suppose I could read each item into an array, and then print them into the new file backwards from the array. But I would think that someone has made this a lot easier in some language - all I need to do is figure out which one.
Any help is appreciated. Sed, awk, perl, bash, C, whatever.




