AWK move lines of a file down
AWK move lines of a file down
(OP)
Hello,
I own
input
and I would like to get
Output
I would like to be able to move lines of a file down according to the number of columns whether with an awk or a sed but without relying on the line number
If anyone had an idea! Thank you very much !
I own
input
CODE --> awk
AB-0004 XXX XXX A8-0005 XXX AB-0007 XXX XXX AB-0008 XXX
and I would like to get
Output
CODE --> awk
AB-0004 XXX XXX AB-0007 XXX XXX A8-0005 XXX AB-0008 XXX
I would like to be able to move lines of a file down according to the number of columns whether with an awk or a sed but without relying on the line number
If anyone had an idea! Thank you very much !
RE: AWK move lines of a file down
RE: AWK move lines of a file down
For example we have this file:
CODE
First, we can use awk to print number of columns (NF = Number of Fields) in every line as the the 1st column
CODE
Then, we can use sort, to sort awk's output according to the 1st column in reverse order
CODE
Finally, we can use cut, to select from sort's output only the second through last columns (fields)
CODE
RE: AWK move lines of a file down