On Wednesday 04 September 2002 9:20 am, Van Den Abeele Kristof wrote: > Hello list , > > > Thx for answering my little 'diff' problem , but I still need some help... > > > I have 2 files (ex.): > > file 1 file 2 > > word u word t > word v word v > word w word z > word x word a > word y > word z > > > I wish to compare those 2 files , and create as output file 3 which consist > of the words in file 1 which are NOT in file 2. In other words , all words > which exist in file 2 should be removed from file 1 > > > so file 3 should be : > > word u > word w > word x > word y > > > Could this be done at command line with some simple instructions , or > should I create a small script ? > > Greetingz & thx for the reply's ... > > Kristof [snip sig even bigger than mine]
Hi Kristof, How's about this for a not too pretty solution: #!/usr/bin/perl -w my %lines=(); die "Usage $0: infile1 infile2 outfile" unless $#ARGV == 2; die "file not found" unless -f $ARGV[0]; die "file not found" unless -f $ARGV[1]; open(FIN,"$ARGV[1]")||die "cannot open $ARGV[1]: $!\n"; $lines{$_}=1 while(<FIN>); close(FIN); open(FIN,"$ARGV[0]")||die "cannot open $ARGV[0]: $!\n"; open(FOUT,">$ARGV[2]")||die "cannot open $ARGV[2]: $!\n"; while (<FIN>) { print FOUT $_ unless defined $lines{$_}; } close(FIN); close(FOUT); -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list