blob: 33aad8d99aa3b8faf59e10cad66de853bb428bcd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/gawk -f
BEGIN {
FIELDWIDTHS = "1:1 3:1 3:1 3:1 3:1 3:1 3:1 3:1 3:1"
while (data[n] !~ /[0-9]/)
getline data[++n]
j = 1
for (i = n - 1; i > 0; i--) {
$0 = data[i]
for (k = 1; k <= NF; k++) {
if ($k != " ")
s[k][j] = $k
}
j++
}
getline # Ignore blank line
FPAT = "[0-9]+"
}
{
# START PART 2
l = length(s[$2])
# END PART 2
for (i = 1; i <= $1; i++) {
# START PART 1
s[$3][length(s[$3]) + 1] = s[$2][length(s[$2])]
delete s[$2][length(s[$2])]
# END PART 1 START PART 2
s[$3][length(s[$3]) + 1] = s[$2][l - $1 + i]
delete s[$2][l - $1 + i]
# END PART 2
}
}
END {
for (i = 1; i <= 9; i++)
printf s[i][length(s[i])]
print ""
}
|