Count column data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Count column data
# 1  
Old 08-10-2012
MySQL Count column data

Hi Guys,


Code:
B07 U51C A1 44 B1 44 Yes
B07 L64U A2 44 B1 44 Yes
B07 L62U A2 44 B1 44 Yes	
B07 L11C A4 32 B1 44 NO
B05 L12Z A1 12 B1 44 NO
B01 651Z A2 44 B1 44 NO
B04 A51Z A2 12 B1 44 NO
L07 B08D A4 12 B1 44 NO
B07 RU8D A4 44 B1 44 Yes
B07 L58D A4 15 B1 44 No
B07 LA8D A4 44 B1 44 Yes
B07 U51C A1 41 B1 44 NO


I want count unix nuber as per last column with uniq data of column 2


Code:
   Yes  NO
A1  1    2   
A2  2    2
A4  2	 3


Thanks
# 2  
Old 08-10-2012
Code:
awk '{ A[$3,$NF]++; B[$3]++ } END { for(X in B) print X, A[X,"Yes"], A[X,"No"] }' file

# 3  
Old 08-10-2012
Bug

Sorry Man

Code:
B07 A1 44 B1 44 Yes
B07 A2 44 B1 44 Yes
B07 A2 44 B1 44 Yes	
B07 A4 32 B1 44 NO
B05 A1 12 B1 44 NO
B01 A2 44 B1 44 NO
B04 A2 12 B1 44 NO
L07 A4 12 B1 44 NO
B07 A4 44 B1 44 Yes
B07 A4 15 B1 44 No
B07 A4 44 B1 44 Yes
B07 A1 41 B1 44 NO

Can you please update the command
# 4  
Old 08-10-2012
Change $3 (i.e. column 3) to $2 (i.e. column 2).
# 5  
Old 08-10-2012
Bug

Still not getting right Answer ????Sir

Last edited by asavaliya; 08-10-2012 at 03:46 PM..
# 6  
Old 08-10-2012
Please check your field positions.
Cheers,
Ranga:-)
This User Gave Thanks to rangarasan For This Post:
# 7  
Old 08-10-2012
Quote:
Originally Posted by asavaliya
Still not getting right Answer ????Sir
In what way did it not work? Be specific.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to insert data into black column( Secound Column ) in excel (.XLSX) file using shell script?

Source Code of the original script is down below please run the script and try to solve this problem this is my data and I want it column wise 2019-03-20 13:00:00:000 2019-03-20 15:00:00:000 1 Operating System LAB 0 1 1 1 1 1 1 1 1 1 0 1 (5 Replies)
Discussion started by: Shubham1182
5 Replies

2. Shell Programming and Scripting

Change data in one column with data from another file's column

Hello, I have this file outputData: # cat /tmp/outputData __Capacity^6^NBSC01_Licences^L3_functionality_for_ESB_switch __Capacity^2100^NBSC01_Licences^Gb_over_IP __Capacity^1837^NBSC01_Licences^EDGE_BSS_Fnc __Capacity^1816^NBSC01_Licences^GPRS_CS3_and_CS4... (1 Reply)
Discussion started by: nypreH
1 Replies

3. Shell Programming and Scripting

Column 2 string count in Column 3

My I/p is Col1|Col2|Col3 2116209997932|POSIX INC|POSIX 2116209997933|POSIX INC|POSIX 2116210089479|POSIX INC|POSIX 2116210180502|POSIX INC|POSIX 2116210512279|POSIX INC|Aero 2116210516838|POSIX INC|POSIX 2116210534342|POSIX INC|postal 2116210534345|POSIX INC|postal ... (6 Replies)
Discussion started by: nikhil jain
6 Replies

4. Shell Programming and Scripting

Read first column and count lines in second column using awk

Hello all, I would like to ask your help here: I've a huge file that has 2 columns. A part of it is: sorted.txt: kss23 rml.67lkj kss23 zhh.6gf kss23 nhd.09.fdd kss23 hp.767.88.89 fl67 nmdsfs.56.df.67 fl67 kk.fgf.98.56.n fl67 bgdgdfg.hjj.879.d fl66 kl..hfh.76.ghg fl66... (5 Replies)
Discussion started by: Padavan
5 Replies

5. Shell Programming and Scripting

Count column data in a text file

I have a text file that has the following column data: 0.007 0.005 0.004 0.007 How do i output the total sum of the data above? (6 Replies)
Discussion started by: alegnagrp
6 Replies

6. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

7. Shell Programming and Scripting

Advanced: Sort, count data in column, append file name

Hi. I am not sure the title gives an optimal description of what I want to do. Also, I tried to post this in the "UNIX for Dummies Questions & Answers", but it seems no-one was able to help out. I have several text files that contain data in many columns. All the files are organized the same... (14 Replies)
Discussion started by: JamesT
14 Replies

8. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

9. Shell Programming and Scripting

row to column and position data in to fixed column width

Dear friends, Below is my program and current output. I wish to have 3 or 4 column output in order to accomodate in single page. i do have subsequent command to process after user enter the number. Program COUNT=1 for MYDIR in `ls /` do VOBS=${MYDIR} echo "${COUNT}. ${MYDIR}" ... (4 Replies)
Discussion started by: baluchen
4 Replies

10. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies
Login or Register to Ask a Question