Comparing between two txt files in Linux

For example I have two text files A and B . I want to compare both files which have numbers . I need to compare A file with B file and write out put to a text file . The condition for comparing A file with B file is list out all numbers that are not present in B file when compared with A file. Any help will be much appreciated.

You can use diff or sdiff command to compare two files in Linux, but the better way is to compare two files using vimdiff command as shown in following screencast. I hope you like it…

 # vimdiff A B

Where A is first file and B is second file…

Here is screencast for better understanding…

Thanks Ravi.

How can I write to another text file the missing numbers in B file?

Yes, you can compare two files and difference output missing numbers to another text file using sdiff command as shown in screencast:

 # sdiff -s A B > C

For better understanding of above command watch the screencast below…

Got it . Thank you Ravi…

@ravisaive, Please tell me, How can you this type of snapshot like video snapshot. Please guide me

We’ve created custom made scripts to create such video snapshots, but you can use SSM Simple Screen Recorder tool to create such awesome videos. Here is the guide that shows how to create such videos…

http://www.tecmint.com/screencasting-with-simple-screen-recorder-in-linux/

1 Like