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 
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.

Post some examples of data in files a.txt and b.txt that you run the following command on:

comm -13 a.txt b.txt
1 Like

Your files must both be sorted for comm to work properly.

Regards,
Alister

Hello , Thanks for your reply. I sorted them before comparing ....

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

Hello Alister ,

thanks for the reply . I just found out answer on

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. :slight_smile:

Ravi Tej.