in reply to comparing 2 files
#!/usr/bin/perl use strict; use warnings; my $table_list_file = shift; # first command-line arg my $table_db_list_file = shift; # second arg my %tables; open( I, "<", $table_list_file ) or die "$table_list_file: $!"; while (<I>) { chomp; $tables{$_} = undef; } open( I, "<", $table_db_list_file ) or die "$table_db_list_file: $!"; while (<I>) { my ( $table_name, $db_name ) = split; # or maybe it's the other wa +y around? if ( $tables{$table_name} ) { # seen in first file? print; } }
And here's a shameless plug for an old post of mine: cmpcol would do this directly, given the following command line, if the files are like what I've assumed above:
In both cases suggested here, you can redirect STDOUT on the command line to create the output file that you want:cmpcol -i -l2 table.list table_db.list
script.file [-options] file1 file2 > output.list
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparing 2 files
by dhudnall (Novice) on Jun 20, 2007 at 14:56 UTC | |
by graff (Chancellor) on Jun 21, 2007 at 02:50 UTC |