______________________________________________________________________
Hey There,
That can be done easily enough with `diff` or `comm`.
diff --changed-group-format='' --unchanged-group-format='%=' <(sort ~/"Downloads/testDiff 01.txt") <(sort ~/"Downloads/testDiff 02.txt")
comm -12 <(sort ~/"Downloads/testDiff 01.txt") <(sort ~/"Downloads/testDiff 02.txt")
Perl works too, although one-liner might fail if there's not a trailing linefeed in each file.
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' ~/"Downloads/testDiff 01.txt" ~/"Downloads/testDiff 02.txt"
These work with files on-disk, but it'd be easy enough to make them function on open BBEdit documents (saved or unsaved).
Here's an AppleScript (operating on window 1 and window 2):
-------------------------------------------------------------------------------------------
set commonLinesList to {}
tell application "TextWrangler"
set doc1Lines to contents of lines of text document 1
set doc2Lines to contents of lines of text document 2
end tell
repeat with i in doc1Lines
if i is in doc2Lines then
set end of commonLinesList to contents of i
end if
end repeat
set AppleScript's text item delimiters to return
tell application "TextWrangler"
make new document with properties {name:"Common-Lines-Unsaved", text:commonLinesList as text}
end tell
-------------------------------------------------------------------------------------------
NOTE: I would not use this script with really massive files.
As usual TMTOWTDI. :)
--
Best Regards,
Chris