match data in two notepads

Go To StackoverFlow.com

-2

I have two notepads and each notepad contains some data. Let's say Notepad 1 and Notepad 2

Notepad 1 contains: A, B, C

Notepad 2 contains: C, D, E

I want to ask that how can i find data in Notepad 2 that contains notepad 1 data. Here answer is C. But i have lots of data in notepad 1 and notepad2. It is not possible to take individual data from notepad 1 and to press Ctrl+F in notepad 2 to find data. Is there any suitable method for this? Will it be possible by converting these notepads into html pages?

2012-04-04 07:52
by Phillipa
by notepads, you mean text files - hjpotter92 2012-04-04 07:54
ya simple text file - Phillipa 2012-04-04 07:55
I do not think this is programming related in any way - bezmax 2012-04-04 07:55
if any solution exists please let me know, can it be achievable by javascript in web pages - Phillipa 2012-04-04 07:57
Javascript can not open text files - bezmax 2012-04-04 07:59
@Max okay but is there any possible way to find out the solution in web pages, i am saying that if there are two html pages then any solution - Phillipa 2012-04-04 08:03
Not sure if troll or just ignoran - Rob Fox 2012-04-04 08:15


1

Probably you'd like to have a look on diff/merge tools. WinMerge is a free one. Another good option is Araxis Merge, it is commercial. Also you can just use Notepad++ editor with its Compare plugin. These tools are GUI based and can help you if you want to see and edit difference.

If you need to extract and somehow automatically process difference, you more likely will have to use some console tools and scripting. *nix diff command can be used to extract difference and there are a lot of scripting languages suitable for text processing: sed, AWK, Perl, Python for instance.

2012-04-04 07:56
by Rorick
are you sure it will work - Phillipa 2012-04-04 08:05
I don't know because it is not clear what you are trying to achieve. If you just want to see the difference then it will work. If you want to extract difference and process it in some way, you'll need to use some console tools like diff and probably sed and/or AWK (on *nix) - Rorick 2012-04-04 08:09


5

This can be done with the comm(1) tool:

$ cat F1
A
B
C
$ cat F2
C
D
E
$ comm -12 F1 F2
C
$ 

The -1 suppresses all lines unique to the first file. -2 suppresses all lines unique to the second file. All that is left is lines common to both.

2012-04-04 09:25
by sarnold
Ads