Hi,
I know it may be taking the biscuit a bit, but further to this thread:
http://www.singletrackworld.com/forum/topic/computer-question-awk-sed-grep-or-anything
I’m making great use of Aidy’s / RichP’s perl / awk commands.
To further optimise my life, any help on the following would be awesome:
The original column of numbers:
0
0
…
0
1
1
…
1
…
n
n
…
n
where n is any positive integer. This column is the third, where the first two represent lat and long.
I would to take the first occurrence of “n”, copy that entire line and replace it after the last occurrence of “n”. For example – in the following simple example we have
x_1 y_1 0
x_2 y_2 0
x_3 y_3 0
x_4 y_4 1
x_5 y_5 1
x_6 y_6 1
x_7 y_7 1
to turn into
x_1 y_1 0
x_2 y_2 0
x_3 y_2 0
x_1 y_1 0
x_4 y_4 1
x_5 y_5 1
x_6 y_6 1
x_7 y_7 1
x_4 y_4 1
And then I can apply the command to the third column to finish the job.
Any help would be much appreciated, it’s either this or cutting and pasting 273 times. I realise this method will add 273 lines to my file.
Many thanks in advance,
Chris