Supposing I have a file F:
hi xb 9 test
hi xc 8 test
hi xa 7 test
I need to sort the lines of this file. But I have two ways I want to sort them.
Method 1: Sort by column. How do I sort the lines by lets say column 2 (xb, xc, xa) or say column 3 (8, 9, 7)?
Expected output if sorted by column 2:
hi xa 7 test
hi xb 9 test
hi xc 8 test
Method 2: Sort by the number on column 3. What is the regex I need to capture the number on column 3?
Expected output:
hi xa 7 test
hi xc 8 test
hi xb 9 test