Need help regarding formatting(comm -23 command)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help regarding formatting(comm -23 command)
# 1  
Old 10-11-2012
Need help regarding formatting(comm -23 command)

Hello all ,

I have two files a.txt and b.txt which have same content . They contain data that is fetched from database through a java program. When I delete a line in a.txt and run the below command
Code:
comm -13 a.txt b.txt

I am not getting the expected result i.e. the line i deleted from a.txt. Instead i am getting the two lines i.e. the line I deleted and the line following it. I am guessing that there is some character in unix at the end of each line that I am not deleting, because of it comm -13 command is failing . Can you please tell how I can remove such special characters ?

thanks.

Last edited by Franklin52; 10-12-2012 at 05:29 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 10-11-2012
Post some examples of data in files a.txt and b.txt that you run the following command on:
Code:
comm -13 a.txt b.txt

This User Gave Thanks to spacebar For This Post:
# 3  
Old 10-11-2012
Your files must both be sorted for comm to work properly.

Regards,
Alister
# 4  
Old 10-11-2012
Hello , Thanks for your reply. I sorted them before comparing ....
# 5  
Old 10-11-2012
You're not going to get any useful help beyond this point (the sort advice) unless you do as spacebar asked and share some sample data. A few lines from each file should be sufficient to demonstrate the issue. Confirm that you can recreate the problem with the small sample. Also show the output you are seeing and the output you desire. Finally, it never hurts to specify which operating system and shell you use.

Regards,
Alister
# 6  
Old 10-11-2012
Hello Alister ,

thanks for the reply . I just found out answer on
https://www.unix.com/unix-dummies-que...n-command.html


Actually I had a shell script , which was not working as desired , I thought its because of comm command , but figured out that its not problem with comm command but with join command . I was not performing a sort before join . Thats the reason for unexpected results.

Thanks a lot for the responses. Smilie

Ravi Tej.
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 ignore Case with in COMM command?

Hi, How can i ignore case between 2 files in unix using COMM command. 2 input files are: -bash-4.1$ more x2.txt HELLO hi HI raj -bash-4.1$ more x3.txt hello hi raj COMM command: -bash-4.1$ comm x2.txt x3.txt hello HELLO hi (3 Replies)
Discussion started by: raju2016
3 Replies

2. Linux

comm command help

The manual does not cover this very well. What do the following compares will do ? 1) comm -13 file1 file2: will it display what is in file2 not in file1? 2) comm -23 file1 file2: will it display what in 1 but not in 2 ? Thanks (5 Replies)
Discussion started by: mrn6430
5 Replies

3. UNIX for Dummies Questions & Answers

Need help with comm command

Hello , I am trying to get contents which are only present in a.csv ,so using comm -23 cat a.csv | sort > a.csv cat b.csv | sort > b.csv comm -23 a.csv b.csv > c.csv. a.csv SKU COUNTRY CURRENCY PRICE_LIST_TYPE LIST_PRICE_EFFECTIVE_DATE TG430ZA ZA USD DF ... (4 Replies)
Discussion started by: RaviTej
4 Replies

4. Shell Programming and Scripting

HPUX and comm command

I need to compare 2 files. I need to see if 1 file has records that are not in a second file. I did some searching and found the 'comm' command. According to the man pages comm -23 test1.txt test2.txt Will tell me what is in file 1 and not in file 2. So I did a simple test test1.txt has the... (3 Replies)
Discussion started by: guessingo
3 Replies

5. UNIX for Dummies Questions & Answers

help on COMM command please

could some one please explain with examples how comm -12 & comm -3 works. I am confused with manual page, Thankyou. (2 Replies)
Discussion started by: Ariean
2 Replies

6. Shell Programming and Scripting

Execution problems with comm command

I tried to compare two sorted files with comm command which contain floating values as: RECT 0 9.8 8.70 7.8 in first file & RECT 0 9.80 8.7 7.80 in second file. comm -3 first_file second_file should give a empty file but it does not. Is there a way to compare these two files correctly... (4 Replies)
Discussion started by: nehashine
4 Replies

7. UNIX for Dummies Questions & Answers

help in comm command

Hi all, I need help in comm command , I am having 2 files . I have to display the common line in the two file only onnce and i have to also display the non common line as well. tmpcut1 -- First file cat tmpcut1 smstr_303000_O_432830_... f_c2_queue_sys30.sys30 RUNNING 10 1000... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

8. Shell Programming and Scripting

comm command

Hi I have issue with "comm " command file-1 ---- l65059 l65407 l68607 l68810 l69143 l71310 l72918 l73146 l73273 l76411 file-2 ----- (8 Replies)
Discussion started by: amitrajvarma
8 Replies

9. UNIX for Advanced & Expert Users

comm command in sorting IP

i have 2 files that contains a sorted list of IP addresses. file_A contains a list of all IPs file_B contains only around 50% of what is in file_A. I tried to execute comm -23 file_A file_B > file_C to get the difference. My objective is to put all the IPs that are in file_A but not... (1 Reply)
Discussion started by: tads98
1 Replies

10. UNIX for Dummies Questions & Answers

Comm, command help

See my other post on sdiff .... I don't think sdiff is able to do what I want. The 'comm' command does what I need and works fine as far as the logic and results. The problem I'm having is with the output format, it outputs 3 columns of data, but because of the way it starts each line... (2 Replies)
Discussion started by: cowpoke
2 Replies
Login or Register to Ask a Question