Thanks for the suggestions!

> On Jan 9, 2016, at 7:25 AM, Christopher Stone <[email protected]> 
> wrote:
> 
> On Jan 08, 2016, at 18:04, Lee Hinde <[email protected]> wrote:
>> I'm doing a Find Differences between two files. I want to copy just the 
>> lines that are different, from both files, into a new document so I can send 
>> that to someone. 
> ______________________________________________________________________
> 
> Hey Lee,
> 
> That's really simple from the command-line.
> 
> # Run from a BBEdit Worksheet:
> 
> diff "/Users/chris/Downloads/Test 01.txt" "/Users/chris/Downloads/Test 
> 02.txt" | sed -En '/[<>]/p'
>> Sometimes you feel like a nut.
>> Testarossa!
> < The ravenous wolf chased Little Red Riding Hood up a tree.
> < Nervous nellies eshew the command-line.
>> Some more text to test with.
> 
> The greater-than and less-than symbols point to which file the line shows up 
> in.
> 
> The different lines are in order from top to bottom.
> 
> From there it's easy to massage the text into the form you want.
> 
> Here's an example script (run using menu #! > Run in BBEdit):
> 
> #! /usr/bin/env bash
> 
> FILE01="/Users/myUserName/Downloads/Test 01.txt";
> FILE02="/Users/myUserName/Downloads/Test 02.txt";
> 
> diffText=$(diff "$FILE01" "$FILE02" | sed -En '/[<>]/p');
> 
> file01Lines=$(sed -En '/^</p' <<< "$diffText");
> file02Lines=$(sed -En '/^>/p' <<< "$diffText");
> 
> file01Lines=$(sed -E 's!^[<][[:blank:]]*!!' <<< "$file01Lines");
> file02Lines=$(sed -E 's!^[>][[:blank:]]*!!' <<< "$file02Lines");
> 
> echo $FILE01;
> echo "";
> echo "$file01Lines"
> echo "";
> echo $FILE02;
> echo "";
> echo "$file02Lines"
> 
> # OUTPUT
> 
> ================================================================================
> Jan 09, 2016, 09:21:42
> untitled text 345
> --------------------------------------------------------------------------------
> /Users/chris/Downloads/Test 01.txt
> 
> The ravenous wolf chased Little Red Riding Hood up a tree.
> Nervous nellies eshew the command-line.
> 
> /Users/chris/Downloads/Test 02.txt
> 
> Sometimes you feel like a nut.
> Testarossa!
> Some more text to test with.
> 
> --
> Best Regards,
> Chris
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or would like to report a problem, please email
> "[email protected]" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to