[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] transpose
From: |
Val Krem |
Subject: |
[Help-bash] transpose |
Date: |
Thu, 26 May 2016 00:56:30 +0000 (UTC) |
Hi all,
I am reading a file with >5M records and with about 15 fields (variables).
I am interested in two of the fields (ID and Flag) and then two fields look
like the following. The first field (ID) is alpha-numeric and the second field
is numeric 0 or 1. My goal is to count the number of 0's and 1's by unique ID
A123 0
A123 0
A123 0
A123 1
A123 1
A123 1
A123 0
A123 0
A123 0
A123 0
A123 1
A123 0
A123 0
A124 0
A124 0
A124 1
A124 1
A124 1
A124 1
A124 0
A124 1
A124 0
A124 0
A124 1
A124 0
A124 1
A124 0
A124 0
A125 0
A125 0
A125 1
A125 1
A125 1
A125 1
A125 0
A125 0
A125 0
A125 0
A125 0
A125 0
A125 1
A125 0
awk '{print $1, $2}' file1 |sort |uniq -c
and got this
9 A123 0
4 A123 1
8 A124 0
7 A124 1
9 A125 0
5 A125 1
Now I want the result to be transposed like this or the
desired output,
A123 9 4
A124 8 7
A125 9 5
I would appreciate if you help me out to get the desired result
thank you in advance
- [Help-bash] transpose,
Val Krem <=