Problems in "comm"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problems in "comm"
# 1  
Old 09-14-2009
Question Problems in "comm"

With respect to my other query I was trying to compare the data in files with "comm" command.

Code:
File -1: (InCU_notDB)
EP120307602281841
EP120607602631482
EP120607602631483
EP120607602631484
EP120607602631485
EP120607602631486
EP120607602631487
EP092905800544601
EP071708601490636
EP071708601490637
EI090409400150849
123456


File -2: (InCU_notDB1)
EP120307602281841
EP120607602631482
EP120607602631483
EP120607602631484
EP120607602631485
EP120607602631486
EP120607602631487
EP092905800544601
EP071708601490636
EP071708601490637
123456

Command used:
comm -12 InCU_notDB InCU_notDB1>c
more c

Output:
EP120307602281841
EP120607602631482
EP120607602631483
EP120607602631484
EP120607602631485
EP120607602631486
EP120607602631487
EP092905800544601
EP071708601490636
EP071708601490637

Question:
Why isnt the value "123456" not included in the output file c?

BTW, I manually added "123456" by using the vi editor. Rest of the values were created by some other code. Just for learning I modified the values to check how it works.

Thanks in advance,

Regards,

Last edited by swame_sp; 09-14-2009 at 05:14 PM.. Reason: adding details..
# 2  
Old 09-14-2009
comm assumes the files are sorted.
# 3  
Old 09-14-2009
thanks...

Oh is it... thanks then.... it wont fit my bill.... Smilie
# 4  
Old 09-14-2009
If you don't mind the alphabetically ordered output:
Code:
comm -12 <(sort -u InCU_notDB) <(sort -u InCU_notDB1)

# 5  
Old 09-14-2009
this also work i guess..
Code:
awk 'FNR==NR{f1[$0];next}$0 in f1' InCU_notDB InCU_notDB1

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. Shell Programming and Scripting

Problems with "write" and "wall"

Hello, I am using VirtualBox to simulate a small network with two Linux computers, the host is Mac OS X. My problem is that I can't send "write" and "wall" messages from the host to one of those Linux computers. Here is what works: - The virtual Linux computer answers "ping" messages that have... (5 Replies)
Discussion started by: 123_abc
5 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

9. UNIX for Dummies Questions & Answers

Can you limit the compare on "comm" command

I need to find deleted records from a file. I compare yesterdays file.old to todays file.new. I need to find the records that were in yesterdays file that are not in todays. My file is fixed field. If I run a "comm -23" obviously what i find is not necesarilly a delete, it could be a change. ... (0 Replies)
Discussion started by: eja
0 Replies
Login or Register to Ask a Question