Working on the same CSV file, extracted about a month ago,
Record types and counts;
How to do it:
Same bash variables set as in previous [Forensics] post.
Who needs SQL?
Read every second record. Starting from Record 1 then Record 2.
lol, right?
Record types and counts;
Code:
0 create_account 13774
1 payment 3421
5 set_options 123
8 account_merge 12803
9 inflation 28
Same bash variables set as in previous [Forensics] post.
Code:
linux> cat $KAG_extract | sed 's/"//g' | awk -F, 'NR>1 {print $4, $5}' | sort -u
account_merge 8
create_account 0
inflation 9
payment 1
set_options 5
cat $KAG_extract | sed 's/"//g' | awk -F, 'NR>1 {print $4, $5}' | sort -u > t1
Code:
linux> for i in 0 1 5 8 9; do echo $i; cat $KAG_extract | sed 's/"//g' | awk -F, -v x=$i '(NR>1) && ($5==x) {print}' | wc -l; done
0
13774
1
3421
5
123
8
12803
9
for i in 0 1 5 8 9; do echo $i; cat $KAG_extract | sed 's/"//g' | awk -F, -v x=$i '(NR>1) && ($5==x) {print}' | wc -l; done > t
linux> for i in 0 1 5 8 9; do echo $i; cat $KAG_extract | sed 's/"//g' | awk -F, -v x=$i '(NR>1) && ($5==x) {print}' | wc -l; done > t
linux> cat t
0
13774
1
3421
5
123
8
12803
9
28
Code:
cat t | sed -n 1~2p > t2
cat t | sed -n 2~2p > t3
linux> cat t | sed -n 1~2p > t2
linux> cat t | sed -n 2~2p > t3
linux> paste t[2-3]
0 13774
1 3421
5 123
8 12803
9 28
linux> paste t[2-3] > t4
Code:
linux> cat t4
0 13774
1 3421
5 123
8 12803
9 28
join -1 2 -2 1 t t4
linux> join -1 2 -2 1 <(sort -k2 t1) t4
0 create_account 13774
1 payment 3421
5 set_options 123
8 account_merge 12803
9 inflation 28