in reply to swapping lines that match a condition
Your "desired result" is identical to your original file.
One solution:
Or if the lines are always adjacent when they're in the wrong order,local $/ = "\n}\n"; while (<>) { s/ ^(fixed-address [^\n]*\n) (.*) ^(hardware ethernet [^\n]*\n) /$3$2$1/xsm; print; }
local $/ = "\n}\n"; while (<>) { s/ ^ (fixed-address .*\n) (hardware ethernet .*\n) /$2$1/xm; print; }
|
|---|