in reply to Re: Sed to perl conversion-- flipping lines in a file
in thread Sed to perl conversion-- flipping lines in a file

This is very cool, Mike. I tried to modify it so that it would only flip lines that met certain conditions (like my sed example above) and went down in flames. Is there a way to get this code to Only swap lines around if the lines contain the following text: '1' or '2' or '3' and to otherwise print the lines in the original file order?

What I really want to get to is something that will convert this highlighted text in vi editor (alas, I am so far in the dark ages my company has not even Heard of Vim, but would probably burn me at the stake for speaking of it):

Line 1 Line 2 Line 3 flip line '1' flip line '2' flip line '3' Line 4 to: Line 1 Line 2 Line 3 flip line '3' flip line '2' flip line '1' Line 4

Does this make more sense to anyone?

Thanks very much for the (hopefully) gentle correction and admonishment, Monks.