Re: How to compare two text files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 06, 2010 at 18:27:12 +0530,
  "W.H. Kalpa Pathum" <callkalpa@xxxxxxxxx> wrote:
> hi,
> 
> I've got two text files containing email addresses one at a row. The
> number of rows in one file is different from the number of the other
> file. email addresses in one file is already there in the other file
> (there are some more also). What I want to do is extract the list
> which is not in the other file.

I do a lot of this at work when needing to deal with lists of accounts.

First make sure the lists are sorted and that there is only one copy of
each address if that makes sense. This assumes that the email addresses
are in a canoical form of some kind.

sort -u file1 > file1.s
sort -u file2 > file2.s

Get lines in file1 but not file2:
comm -2 -3 file1 file2

Note that you might need sort and comm using the same locale for their sort.
On some old machines I have had one using LANG_C whole the other used
en_US, which caused problems when there is mixed case. I don't think that
will be an issue with Fedora.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux