Transposing Repeated Rows to Columns.

I have 1000s of these rows that I would like to transpose to columns. However I would like the transpose every 3 consecutive rows to columns like below, sorted by column 3 and provide a total for each occurrences. Finally I would like a grand total of column 3.

21|FE|41|0B
50\65\78
15
|C3|21|A0|B2
20\64\217
4
|C3|1F|D9|D4
43\146\60
14
21|FE|3F|D9
10\31\243\70
18
C3|21|9E|30
101\146\56
20
21|FE|60|D6
50\133\251
15
21|FE|8E|C3
4\195\117
15
21|FE|60|18
51\70\241
15
|21|FE|62|3E
55\69\248
15
21|FE|5F|4B
42\195\44
14
21|FE|3A|A3
42\199\114
14
21|FE|35|D9
55\195\31
15
21|FE|3E|6E
105\224\102
20
21|FE|35|E9
54\130\73
15
|21|FE|62|4B
51\72\225
15
21|FE|5B|86
54\64\134
15
21|FE|42|E6
52\65\123
15
21|FE|57|17
104\128\192
20
21|FE|53|04
104\131\18
20

Output

Column 1   Column 2   Column 3       
|C3|21|A0|B2   20\64\217   4       
|C3|1F|D9|D4   43\146\60   14       
21|FE|5F|4B   42\195\44   14       
21|FE|3A|A3   42\199\114   14       
21|FE|41|0B   50\65\78   15      
21|FE|60|D6   50\133\251   15       
21|FE|8E|C3   4\195\117   15       
21|FE|60|18   51\70\241   15       
21|FE|62|3E   55\69\248   15       
21|FE|35|D9   55\195\31   15       
21|FE|35|E9   54\130\73   15      
 |21|FE|62|4B   51\72\225   15       
21|FE|5B|86   54\64\134   15       
21|FE|42|E6   52\65\123   15       

Total for   Catalog: 15   14       
 
21|FE|3F|D9   10\31\243\70   18       

Total for   Catalog: 18   1       

C3|21|9E|30   101\146\56   20       
21|FE|3E|6E   105\224\102   20      
21|FE|57|17   104\128\192   20       
21|FE|53|04   104\131\18   20       
  
 Total for   Catalog: 20   4       
    
 Grand Total   Catalogs   19   

The following code will give you the data with three sorted columns:

paste -d' ' - - - < In_File | sort -nk3 Out_file
1 Like

Awesome! This works perfectly! Shell essentially I can add more "-" dashes with respect to the rows?
I'll have to improvise something with awk to accomplish the counts and totals.
Thanks again!