Getting count of Key in another file


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Getting count of Key in another file
# 1  
Old 04-05-2018
Getting count of Key in another file

Hi All,

I need to find the count of key occurrence from one file corresponding to another file. Any help please. I am planning to read the CUST_ID in a while loop and do a grep , is there a way to do easier

Code:
CUST_ID
677582806078
687582821181
687582828910
687582834580
687582834849
687582836290
687582838298
687582838925
687582838926
687582839317

TRANSACTION
2002;20140630;0000;0002000000;1109500248;677582806078;0.00
2002;20140630;0000;0002000000;1109500248;677582806078;0.00
2002;20140630;0000;0002000000;1109500248;91227510334;0.00
2002;20140630;0000;0002000000;1109500248;91227810199;0.00
2002;20140630;0000;0002000000;1109500248;91277010605;0.00
2002;20140704;0000;0002000000;1109500248;639867328;0.00
2002;20140704;0000;0002000000;1109500248;1700306519;0.00
2002;20140704;0000;0002000000;1109500248;687582838926;0.00
2002;20140704;0000;0002000000;1109500248;687582838926;2.98
2002;20140704;0000;0002000000;1109500248;687582834580;2.99

OUTPUT
677582806078 ---> 2
687582838926 ---> 2
687582834580 ---> 1

# 2  
Old 04-05-2018
Hi, try:
Code:
awk 'NR==FNR{C[$6]++; next} $1 in C{print $1, C[$1]}' FS=\; file2 FS=" " file1

This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert rows to columns based on key and count

Team, I am having requirement to convert rows to columns Input is: key ,count, id1, pulse1, id2, pulse2 ,id3, pulse3 12, 2 , 14 , 56 , 15, 65 13, 3, 12, 32, 14, 23, 18, 54 22, 1 , 32, 42 Expected Out put: key, id,pulse 12, 14, 56 12, 15, 65 13 ,12, 32 13, 14 ,23 13, 18 ,54 22 ,32,... (3 Replies)
Discussion started by: syam1406
3 Replies

2. Shell Programming and Scripting

How to extract information a file according key id in another file?

hi, i have a large file containing the detailed information of a bunch of keys like this: JAT_0001 contig102_342_3_n2 contig102_342 atgcacgacta 30 50 20... (11 Replies)
Discussion started by: the_simpsons
11 Replies

3. Shell Programming and Scripting

Searching the content of one file using the search key of another file

I have two files: file 1: hello.com neo.com,japan.com,example.com news.net xyz.com, telecom.net, highlands.net, software.com example2.com earth.net, abc.gov.uk file 2: neo.com example.com abc.gov.uk file 2 are the search keys to search in file 1 if any of the search key is... (3 Replies)
Discussion started by: csim_mohan
3 Replies

4. Solaris

Solaris 8 ssh public key authentication issue - Server refused our key

Hi, I've used the following way to set ssh public key authentication and it is working fine on Solaris 10, RedHat Linux and SuSE Linux servers without any problem. But I got error 'Server refused our key' on Solaris 8 system. Solaris 8 uses SSH2 too. Why? Please help. Thanks. ... (1 Reply)
Discussion started by: aixlover
1 Replies

5. Shell Programming and Scripting

Count the delimeter from a file and delete the row if delimeter count doesnt match.

I have a file containing about 5 million rows, in the file there are some records which has extra delimiter at random position. (we dont know the positions), now we have to Count the delimeter from each row and if the count of delimeter is not matching then I want to delete those rows from the... (5 Replies)
Discussion started by: Akumar1
5 Replies

6. Shell Programming and Scripting

Using Key to get data from second file

I posted a problem last week that had essentially two steps. Someone was kind enough to help me with the first step, but beacuse I didn't explain things well, left out the second step. I'm required to work in C Shell. I deeply appreciate any help, since I've never worked in a shell language... (4 Replies)
Discussion started by: bassmaster
4 Replies

7. Shell Programming and Scripting

Getting Sum, Count and Distinct Count of a file

Hi all this is a UNIX question. I have a large flat file with millions of records. col1|col2|col3 1|a|b 2|c|d 3|e|f 3|g|h footer**** I am supposed to calculate the sum of col1 1+2+3+3=9, count of col1 1,2,3,3=4, and distinct count of col1 1,2,3=c3 I would like it if you avoid... (4 Replies)
Discussion started by: singhabhijit
4 Replies

8. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

9. UNIX for Dummies Questions & Answers

How to count the record count in an EBCDIC file.

How do I get the record count in an EBCDIC file on a Linux Box. :confused: (1 Reply)
Discussion started by: oracle8
1 Replies
Login or Register to Ask a Question