The following requirement is to add the record with Subsequent columns to the previous Record as an additional Column
Input Data
1|AB|1|20||PAR 1234|||1
1|AB|1|20||PAR 1234|||1
||||SIR 234|||1
1|AB|1|20||PAR 456|||2
1|AB|1|20||PAR 233|||2
||||SIR 236|||1
1|AB|1|20||PAR 123|||2
||||SIR 236|||1
||||IL 236|||1
Query
As per the output below; we need to add SIR 234 in the previous Record as a last column and delete the next line, like wise for SIR 236 and to the last of the file, Wanted to use Awk but not getting how.
Expected Output
1|AB|1|20||PAR 1234|||1
1|AB|1|20||PAR 1234|||1|SIR 234
1|AB|1|20||PAR 456|||2
1|AB|1|20||PAR 233|||2|SIR 236
1|AB|1|20||PAR 123|||2|SIR 111|IL 236
Not to sure how to Try AWK in this scenario I tried the very basic ones but is giving an error, awk -F, '{print > $6".txt"}' file
See Question&Answers more detail:os