Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

compare two text files - script  please

Posted on 2014-02-10
5
Medium Priority
?
464 Views
Last Modified: 2014-02-10
i have 2 list of hotfix updates from two computers.  I need to compare (working computer) against none working computer.

Is there a script or freeware program that I can use that will tell me what exist in working but doesn't exist in nonworking.  I don't want it to compare the file line for line exact i want it to search and see if it exist in one and not the other.

Thanks!
0
Comment
Question by:bbimis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 1000 total points
ID: 39847815
The following works in Linux and Unix:

Both files must be sorted, then you can use "comm":

sort working > working.sort
sort nonworking > nonworking.sort

comm -2 -3 working.sort nonworking.sort

will show all lines that are only in the first file.

Likewise

comm -1 -3 working.sort nonworking.sort

will show all lines that are only in the second file and

comm -1 -2 working.sort nonworking.sort

will show all lines that are common to both files.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39847885
For Windows, there is e.g. "winmerge":
http://winmerge.org/

A "comm" implementation is shipped with MobaXterm:
http://mobaxterm.mobatek.net/

This tool is also an SSH/telnet/rsh client and an X-server, based on BusyBox.
It comes in a single portable exe file which works out of the box.
http://mobaxterm.mobatek.net/
0
 
LVL 57

Accepted Solution

by:
Bill Prew earned 1000 total points
ID: 39847909
A great free tool for this at http://winmerge.org/

Just take the two text files you want to compare, sort them (can use the command line SORT tool) and then compare the sorted outputs.

~bp
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39847916
I believe the solid freeware editor Notepad++ also has a "compare" mode where you can see the differences between two files.  Again, you want to do that after sorting each.

http://notepad-plus-plus.org/

~bp
0
 

Author Closing Comment

by:bbimis
ID: 39848244
thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question