[lug] parsing between two lists

qqq1one @yahoo.com qqq1one at yahoo.com
Wed Mar 27 23:25:00 MST 2002


This is pretty slick.  I didn't know about that unified output option
(-u) on grep.  And someone later mentioned to use cut instead of sed. 
That's another one I didn't know about.  I also like how you get the
name of the file with the output when you do one of the "unique in
list" parses.  Combining all this with the temporary file I get:

diff -u listA listB > diffAB
grep ^-   diffAB | cut -c 2- (unique in listA)
grep ^+   diffAB | cut -c 2- (unique in listB)
grep "^ " diffAB | cut -c 2- (common to both)

--- "Riggs, Rob" <RRiggs at doubleclick.net> wrote:
> Unique in list A: diff -u listA listB | grep ^- | sed 's/^.//g'
> Unique in list B: diff -u listA listB | grep ^+ | sed 's/^.//g'
> Common to both: diff -u listA listB | grep "^ " | sed 's/^.//g'
> 
> -----Original Message-----
> From: qqq1one @yahoo.com [mailto:qqq1one at yahoo.com]
> Sent: Tuesday, March 26, 2002 10:34 PM
> To: lug at lug.boulder.co.us
> Subject: [lug] parsing between two lists
> 
> 
> If, using "sdiff fileA fileB", I get a listing that looks like this:
> 
>     alien         alien
>     allegro     | alsa-lib-devel
>     alsaplayer  | Alsa-sound-mini-HOWTO
>     alsa-utils    alsa-utils
>     etc...
> 
> ...but I would rather have a list that shows what's in fileA that's
> not
> in fileB:
> 
>     allegro
>     alsaplayer
>     etc...
> 
> and another list that shows what's in fileB that's not in fileA:
> 
>     alsa-lib-devel
>     Alsa-sound-mini-HOWTO
>     etc...
> 
> and perhaps even another list that shows what is common between listA
> and listB:
> 
>     alien
>     alsa-utils
>     etc...
> 
> is there a way to do this using sdiff?  Or perhaps a grep embedded in
> some script?  Or is there yet another approach altogether that would
> work better?
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Movies - coverage of the 74th Academy Awards®
> http://movies.yahoo.com/
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug






__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/



More information about the LUG mailing list