Displaying difference of 2 files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Displaying difference of 2 files
# 1  
Old 06-25-2010
Displaying difference of 2 files

Hi All,

Got this 2 file namely a.txt and b.txt, i want to know how to extract the difference between the two files, the output will be written to a file.

e.g.
>>a.txt<<
Code:
Nokia 1100
Nokia 1200
Nokia 1300
Nokia 1400
Nokia 1500
Nokia 1600
Nokia 1700
Nokia 1701
Nokia 1702
Sagem 1100
Nokia 1201

>>b.txt \<<
Code:
Nokia 1100
Sagem 1100
Nokia 1700
Nokia 1200
Nokia 1300
Nokia 1400
Nokia 1500
Nokia 1201
Nokia 1202
Nokia 1203
Nokia 1701

Moderator's Comments:
Mod Comment Use code tags please, ty.

Last edited by zaxxon; 06-25-2010 at 06:04 AM.. Reason: code tags
# 2  
Old 06-25-2010
Code:
sort a.txt > a1.txt
sort b.txt > b1.txt

diff a1.txt b1.txt

This User Gave Thanks to a_programmer For This Post:
# 3  
Old 06-25-2010
Hi,

Thanks.

So i need to sort it first, so that i have accurate result. I will test it later. Smilie
# 4  
Old 06-25-2010
u dnt need to sort, the diff command will run without that also.
Code:
 diff file 1 file 2

it will show the diffrence between 2 files on ur machine..
Code:
diff file 1 file 2 >> out.file

nw the difference will be stored in out.file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing fields of two files and displaying results

Hello , I am trying to compare two files i.e one master file and the other exclusion file. If the second field of masterfile is oracle8 then I need to compare the 3rd field of master file with the 1st field of all the rows of exclusion file else I need to compare 2nd field from master file with... (2 Replies)
Discussion started by: rahul2662
2 Replies

2. Shell Programming and Scripting

Help with displaying difference between two arrays (Bash)

The code I have is kind of long, so I'm just posting the part I'm struggling with. I've found many examples online of comparing two arrays in Bash and printing the difference between them. I've tried them all, even mixed and matched some examples with no luck. I know this can't be as hard as I'm... (9 Replies)
Discussion started by: Azrael
9 Replies

3. Shell Programming and Scripting

Perl: Comparing to two files and displaying the differences

Hi, I'm new to perl and i have to write a perl script that will compare to log/txt files and display the differences. Unfortunately I'm not allowed to use any complied binaries or applications like diff or comm. So far i've across a code like this: use strict; use warnings; my $list1;... (2 Replies)
Discussion started by: dont_be_hasty
2 Replies

4. Shell Programming and Scripting

Displaying Files Problem

To match all filename comprising at least three characters the first character is numeric and the last character is not alphabetic (2 Replies)
Discussion started by: polineni
2 Replies

5. Shell Programming and Scripting

Displaying Files Problem

To match all filename comprising at least three characters not beginning with a dot (1 Reply)
Discussion started by: polineni
1 Replies

6. Shell Programming and Scripting

Displaying list of backup files using for loop

Hi, I want to display list of last 10 backup files (with numbering) from the temporary file c:/tmp/tmp_list_bkp.txt Example : 1) backup_file1 2) backup_file2 3) backup_file3 ........ ........ I tried as below but not working. for file in c:/tmp/tmp_list_bkp.txt do echo... (3 Replies)
Discussion started by: milink
3 Replies

7. AIX

Russian fonts not displaying in AIX PDF files

Hi, We have an issue with russian cyrillic fonts that are not displayed correctly in pdf when application works in AIX . The same russian fonts are displayed properly in windows machine. There are spaces between russian characters and also cyrillic fonts are overlapping in AIX... (3 Replies)
Discussion started by: jinto
3 Replies

8. Shell Programming and Scripting

Displaying a list of files

Given a set of log files like trail.<timestamp> that are generated hourly, how do I get the list of files created for the current date, using shell script? Can anyone please help me?the format of the trace file is trail.YYYYMMDDhh I also need to know how I can "grep" for a particular word in these... (2 Replies)
Discussion started by: ggayathri
2 Replies

9. UNIX for Dummies Questions & Answers

Displaying files in a directory

Dear Experts, I am new to UNIX and I have a script below and in this test case I am reading the names of the files in the present directory into a variable and then looping through each file name and displaying the name back to the screen. The problem I have is although there are 5 files in the... (4 Replies)
Discussion started by: markjohnlowe
4 Replies

10. Shell Programming and Scripting

Displaying files

I am beginner to UNIX. I wanted to display 5 filesname with size from BIN directory. The order of display should be descending order in size. Can help me. (1 Reply)
Discussion started by: giridher2000
1 Replies
Login or Register to Ask a Question