You can play with the 'x' command to exchange the hold and the pattern space. Provided that the following will print a blank line (which is in the hold space at start-up) followed by all the lines except the last one (which is retained in the hold space and never printed out):
you have to insert two rules to manage the first and the last line:
Code:
sed -n 'x;1d;p;${x;p}' file
this deletes the first line (which is the blank line line exchanged with the hold buffer) and print out the last one, since ${x;p} matches the end of the file and exchanges again the pattern space with the hold buffer, so that the last line is released and printed out. This actually prints out the entire file, but every time it parses a new input line, it retains the previous one in the hold buffer.
Now we have to establish a rule to manage the matching line. I would use an extended regexp and the following commands:
Code:
sed -rn '/(0\.0000 *){6}/{n;n;x;d};x;1d;p;${x;p}' file
where it reads in the next two lines, then it exchanges the hold buffer and delete the previously stored line (this solves your struggle). Now the hold buffer contains the second line after the match. It will be printed out at the next pass.
Hope it's clear. Not easy to explain, but I assumed you had a look at
http://www.grymoire.com/Unix/Sed.html... a must-read!