BASH: Swap first two lines in sets of 4

Hi.

I may have mentioned in the OP to this thread that the AHK macro script I was trying to sort was, relative to its full length, only partly in the right format to be sorted by the methods discussed in that thread.

Now I'm looking to tackle the rest of the data in that AHK script.

Example data:

::god::
;Great Outdoors
Send, Great Outdoors,
Exit

::sand::
;On The Beaches
Send, On The Beaches,
Exit

::budapest::
;Hungarian Honeys
Send, Hungarian Honeys,
Exit

::ukgirl::
;British Birds & Belles
Send, British Birds & Belles, 
Exit

::fool::
;Getting Goofy::
Send, Getting Goofy,
Exit

I did the first one by hand (actually by using some awk commands in terminal) to show what I mean by "swap."

;Great Outdoors
::god::
Send, Great Outdoors,
Exit

Now I'm looking to automate the process for the rest of the data that's formatted as the above. In my C&P from the original AHK file, I count 45 such "quatrains" (4-line sets of data). I may have missed some in cutting and pasting.

Though the subject line of this OP says "BASH," I am, of course, not partial to it. Perl solutions are also welcome.

BZT

awk -F'\n' '{
  print $2, $1, $3, $4
  }' OFS='\n' RS= ORS='\n\n' infile
1 Like

Works. TYVM. BZT