Fred Stluka via plug on 1 Jun 2021 17:10:33 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Using diff


Rich,

I've done this before with diff, and used grep to filter out all the noise
and less to show the results with the parts I cared about highlighted.
But comm works much better.  Good tip!  Thanks!

Here's what my old script did, when comparing new and old folders
of mailing lists to see who was deleted from, and especially added
to each list:

echo "Comparing new and old lists..."
# |& = Pipe both stdout and stderr
# -v = Lines NOT containing the pattern
# -x = Only if the pattern matches the ENTIRE line
# -e = Treat pattern as pattern, NOT as an option, even if it starts with -
# "^[0-9]" = Lines starting with digits like:  2509a2511, 187c187, 348d347
# -I = Ignore case in searches
# -+F = Don't exit less if one screen or less
# "+/^(> |[^<>].*)" = Find and highlight all occurrences of "> " at the
#                     start of a line, and the entire line for all lines
#                     not starting with < or >.  This makes it easier to
#                     scan for additions to lists, while noting deletions.
diff . ./OLD |& grep -v -x -e "---" | grep -v "^[0-9]" | less -I -+F "+/^(> |[^<>].*)"

--Fred
------------------------------------------------------------------------
Fred Stluka -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------

On 5/28/21 12:40 PM, Rich Kulawiec via plug wrote:
On Thu, May 27, 2021 at 05:37:33PM -0400, Michael Lazin via plug wrote:
I used the sort command to make two lists.  One list has everything on the
first list and more.  They are already alphabetically sorted.  I want to
know what is on the second list that is not on the first list.  I am trying
to use diff but perhaps there is a better way.   I tried awk and an ugly
egrep and now I am giving up and asking for help.  Thanks for your time.
	% comm -13 file1 file2

---rsk
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug