in reply to Help creating HASH for file comparison
If you're on a Unix system, don't use Perl. Sort each file on the second column, then use the 'join' command twice to find (a) lines that are common to both files, and (b) lines in one file that aren't in the other. The first group can then be further processed as desired.
# sort the first file by the second column (zero-indexed) sort -n -t , +1 f1 >s1 # sort the second file by the second column (zero-indexed) sort -n -t , +1 f2 >s2 # print lines whose second column (one-indexed) # are common to both files join -t , -1 2 -2 2 s1 s2 # print lines in file 1 that are NOT in file 2 join -t , -1 2 -2 2 -v 1 s1 s2
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Help creating HASH for file comparison
by space_monk (Chaplain) on Mar 27, 2013 at 21:14 UTC | |
Re^2: Help creating HASH for file comparison
by jb60606 (Acolyte) on Mar 27, 2013 at 21:53 UTC |
In Section
Seekers of Perl Wisdom