Hi All,
Sorry if this question has been posted elsewhere, but I'm hoping someone can help me! Bit of an AWK newbie here, but I'm learning (slowly!)
I'm trying to cobble a script together that will save me time (is there any other kind?), to swap two fields (one containing whitespace), with each field on different lines
As an arbitrary example (I'll explain as best as I can!):
ENTRANT LIST
Name Entry Type Fastest Time
--------------------------------------------
Andrew Cyclist 10:59 #(newline here)
Cyclist Mr. Smith has a great track record....
******************************
Chris Runner 45:12
Runner Mr. Jones has been an avid runner for....
******************************
Now my problem is this: I want to Switch $1 of the first line ("Andrew") with $2 of the second line ("Mr. Smith" [note whitespace]) to give me:
ENTRANT LIST
Name Entry Type Fastest Time
--------------------------------------------
Mr. Smith Cyclist 10:59 #(newline here)
Cyclist Andrew has a great track record....
******************************
Im assuming I'll need to use the *s as record separator and operate from there, but I'm coming up short on:
A) How to read two lines at once - presumably I will need a third area in memory to store one of the fields while the other is moved- should I create a temp file for this?
B) Avoiding having 'Mr. Smith' separated into two fields.
I'm trying to avoid creating two arrays if possible, but I can see this being the only way - does anybody have any suggestions about how I could approach this another way?
Sorry for all the questions - hopefully someone can help me out!