You are here: PSPad forum > English discussion forum > diff using to check common lines

diff using to check common lines

#1 diff using to check common lines

Posted by: sellige | Date: 07/23/2017 19:17 | IP: IP Logged

Hello,

I want to compare two files and put common lines into a third file.

Is it possible with the diff function, or another way?

I think it is possible to put differences in another file , but not common lines.

Thank you

Options: Reply | Quote | Up ^


#2 Re: diff using to check common lines

Posted by: vbr | Date: 07/24/2017 10:59 | IP: IP Logged

sellige:
Hello,
I want to compare two files and put common lines into a third file.
Is it possible with the diff function, or another way?
I think it is possible to put differences in another file , but not common lines.
Thank you

Hi,
currently, I can only think about a workaround using the present functionality:
After performing the comparison, use "Both windows into new file" via the icon "results processing".
In this joined file, You can search for identical line parts using a regular expression :

In the Find dialog (Ctrl+F) check [x] Regular expression
search e.g. for:
^([^|]*) +\| \1$

Use the [Copy] button to get a list of matching "doubled" lines in a new file.
Here You can use regular expression replacement:
^([^|]*) +\| \1$
replace with:
$1

To get the list of the original lines common for both texts.

This way is inexact with regard to whitespace (because of the added space padding of the comparison results).
The original data also must not contain the separator | (in such cases it would require a more complex handling).

hth,
vbr

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2017 Jan Fiala
Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák