The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: awk help
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 07-17-2008
jkl_jkl jkl_jkl is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 46
I tried upto this


Code:
$ awk '$2==0' file.txt > file.txt.0
$ awk '$2==1' file.txt > file.txt.1

$ cat file.txt.0
7789 0
1223 0
4567 0
7789 0
7789 0
3445 0

$ cat file.txt.1
3445 1
7789 1
1212 1
7789 1
3445 1

<0 entries>
$ awk '{count[$1]++}END{for(j in count) print j,count[j]}' file.txt.0
1223 1
4567 1
7789 3
3445 1

<1 entries>
$ awk '{count[$1]++}END{for(j in count) print j,count[j]}' file.txt.1
7789 2
3445 2
1212 1