![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Comparing two files | guptan | Shell Programming and Scripting | 5 | 08-04-2008 08:02 AM |
| Comparing two files... | paqman | Shell Programming and Scripting | 12 | 08-08-2007 03:45 AM |
| Paste the files contents differently | er_aparna | Shell Programming and Scripting | 1 | 05-16-2007 04:29 AM |
| comparing shadow files with real files | terrym | UNIX for Advanced & Expert Users | 4 | 02-09-2007 02:38 AM |
| comparing files to contents of a file | SummitElse | Shell Programming and Scripting | 3 | 06-28-2006 12:36 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Comparing contents of files
Hi,
I hav two files a1.txt and a2.txt, a1.txt contains: --------------- asdev ebcdev .... a2.txt contains: --------------- asdev ebcdev prod .... a1.txt will be updated by a process,.. now i want to compare two files and i want to see data which is not in a1.txt am i clear....?? regards leenus |
|
||||
|
Use this perl code for your solution
Code:
#!/usr/bin/perl
open(FILE, "<", "a1.txt" ) || die "Unable to open file a <$!>\n";
while ( <FILE> ) {
chomp;
$fileHash{$_} = $i++;
}
close(FILE);
open(FILE, "<", "a2.txt" ) || die "Unable to open file a <$!>\n";
while( <FILE> ) {
chomp;
if( exists $fileHash{$_} ) {
}
else {
print "$_\n";
}
}
close(FILE);
exit 0
Mukund Ranjan ![]() Last edited by mukundranjan; 04-03-2007 at 08:15 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|