sarenace |
11-23-2012 08:21 PM |
Calling sort from within awk on multiline input
Hello,
I have a file with records that I'm filtering with the awk command
Quote:
awk '/PokerStars/,/\n\n\n/{if(/^Seat/)print; else if (/^$/)print}'
|
to give output like this:
Quote:
Seat 1 amkolino (13821 in chips)
Seat 2 Hed1ng (11044 in chips)
Seat 3 potiss... (5048 in chips)
Seat 4 [KPACABKA77] (8954 in chips)
Seat 5 Rob1991315 (10390 in chips)
Seat 6 remajr (25462 in chips)
Seat 7 mikelong11 (6286 in chips)
Seat 8 sarenace (14492 in chips)
Seat 9 nikoo-36 (12462 in chips)
Seat 1 amkolino (big blind) folded before Flop
Seat 2 Hed1ng folded before Flop (didn't bet)
Seat 3 potiss... folded before Flop (didn't bet)
Seat 4 [KPACABKA77] showed [As 7s] and won (20108) with two pair, Aces and Sevens
Seat 5 Rob1991315 folded before Flop (didn't bet)
Seat 6 remajr folded before Flop (didn't bet)
Seat 7 mikelong11 folded before Flop (didn't bet)
Seat 8 sarenace (button) showed [Ks Kc] and lost with a pair of Kings
Seat 9 nikoo-36 (small blind) folded before Flop
Seat 1 amkolino (11996 in chips)
Seat 2 Hed1ng (9619 in chips)
Seat 3 potiss... (4823 in chips)
Seat 4 [KPACABKA77] (22908 in chips)
Seat 5 Rob1991315 (10165 in chips)
Seat 6 remajr (25237 in chips)
Seat 7 mikelong11 (6061 in chips)
Seat 8 sarenace (5413 in chips)
Seat 9 nikoo-36 (11737 in chips)
Seat 1 amkolino (button) folded before Flop (didn't bet)
Seat 2 Hed1ng (small blind) folded before Flop
Seat 3 potiss... (big blind) showed [Kh 7d] and lost with high card Ace
Seat 4 [KPACABKA77] folded before Flop (didn't bet)
Seat 5 Rob1991315 folded before Flop (didn't bet)
Seat 6 remajr folded before Flop (didn't bet)
Seat 7 mikelong11 folded before Flop (didn't bet)
Seat 8 sarenace showed [6s 3s] and lost with high card Ace
Seat 9 nikoo-36 showed [Ts Ks] and won (16999) with a pair of Tens
|
What I want to do is sort each block of text by the seat number, i.e., the ouput I want should read:
Quote:
Seat 1 amkolino (13821 in chips)
Seat 1 amkolino (big blind) folded before Flop
Seat 2 Hed1ng (11044 in chips)
Seat 2 Hed1ng folded before Flop (didn't bet)
Seat 3 potiss... (5048 in chips)
Seat 3 potiss... folded before Flop (didn't bet)
Seat 4 [KPACABKA77] (8954 in chips)
Seat 4 [KPACABKA77] showed [As 7s] and won (20108) with two pair, Aces and Sevens
Seat 5 Rob1991315 (10390 in chips)
Seat 5 Rob1991315 folded before Flop (didn't bet)
Seat 6 remajr (25462 in chips)
Seat 6 remajr folded before Flop (didn't bet)
Seat 7 mikelong11 (6286 in chips)
Seat 7 mikelong11 folded before Flop (didn't bet)
Seat 8 sarenace (14492 in chips)
Seat 8 sarenace (button) showed [Ks Kc] and lost with a pair of Kings
Seat 9 nikoo-36 (12462 in chips)
Seat 9 nikoo-36 (small blind) folded before Flop
Seat 1 amkolino (11996 in chips)
Seat 1 amkolino (button) folded before Flop (didn't bet)
Seat 2 Hed1ng (9619 in chips)
Seat 2 Hed1ng (small blind) folded before Flop
Seat 3 potiss... (4823 in chips)
Seat 3 potiss... (big blind) showed [Kh 7d] and lost with high card Ace
Seat 4 [KPACABKA77] (22908 in chips)
Seat 4 [KPACABKA77] folded before Flop (didn't bet)
Seat 5 Rob1991315 (10165 in chips)
Seat 5 Rob1991315 folded before Flop (didn't bet)
Seat 6 remajr (25237 in chips)
Seat 6 remajr folded before Flop (didn't bet)
Seat 7 mikelong11 (6061 in chips)
Seat 7 mikelong11 folded before Flop (didn't bet)
Seat 8 sarenace (5413 in chips)
Seat 8 sarenace showed [6s 3s] and lost with high card Ace
Seat 9 nikoo-36 (11737 in chips)
Seat 9 nikoo-36 showed [Ts Ks] and won (16999) with a pair of Tens
|
I tried to achieve this by calling the sort command from within awk:
Quote:
awk '/PokerStars/,/\n\n\n/{if(/^Seat/){
close("sort -k2,n")
print
}else if(/^$/)print}'
|
However this makes no change to the output. Would anyone know whats going on?
|