Discussion:
syntax of "find" - am I losing my mind?
Add Reply
Kenny McCormack
2024-12-27 20:08:53 UTC
Reply
Permalink
I'm trying to find all files in my home dir that are not in group foo or
group bar. Most of my files are in one or the other of these groups.

This is my tcsh command line:

% find ~ -xdev \! \( -group foo -o -group bar \) -ls

This dumps out every file. It should just dump out a few. Why?

I tried replacing \! with -not and I tried replacing -o with -or.
Neither helped.

I'm sure I've done this sort of thing in the past (successfully).
--
"I think I understand delicate, but why do I have to wash my hands, and
be standing in cold water when doing it?"

Kaz Kylheku <***@kylheku.com> in comp.lang.c
Wayne
2024-12-27 21:29:25 UTC
Reply
Permalink
The "-ls" doesn't work as yoiu expect. Try something like -print or
-printf instead.
--
Wayne
Post by Kenny McCormack
I'm trying to find all files in my home dir that are not in group foo or
group bar. Most of my files are in one or the other of these groups.
% find ~ -xdev \! \( -group foo -o -group bar \) -ls
This dumps out every file. It should just dump out a few. Why?
I tried replacing \! with -not and I tried replacing -o with -or.
Neither helped.
I'm sure I've done this sort of thing in the past (successfully).
marrgol
2024-12-27 21:39:14 UTC
Reply
Permalink
Post by Kenny McCormack
I'm trying to find all files in my home dir that are not in group foo or
group bar. Most of my files are in one or the other of these groups.
% find ~ -xdev \! \( -group foo -o -group bar \) -ls
This dumps out every file. It should just dump out a few. Why?
I tried replacing \! with -not and I tried replacing -o with -or.
Neither helped.
I'm sure I've done this sort of thing in the past (successfully).
$ find ~ -xdev -not -group foo -not -group bar -ls
marrgol
2024-12-27 21:59:30 UTC
Reply
Permalink
Post by marrgol
Post by Kenny McCormack
I'm trying to find all files in my home dir that are not in group foo or
group bar. Most of my files are in one or the other of these groups.
% find ~ -xdev \! \( -group foo -o -group bar \) -ls
This dumps out every file. It should just dump out a few. Why?
I tried replacing \! with -not and I tried replacing -o with -or.
Neither helped.
I'm sure I've done this sort of thing in the past (successfully).
$ find ~ -xdev -not -group foo -not -group bar -ls
I've just tried your version too and both give the the same and correct
result -- are you sure you are using GNU findutils find? Mine is v4.8.0.
Kaz Kylheku
2024-12-27 21:57:52 UTC
Reply
Permalink
Post by Kenny McCormack
I'm trying to find all files in my home dir that are not in group foo or
group bar. Most of my files are in one or the other of these groups.
% find ~ -xdev \! \( -group foo -o -group bar \) -ls
It works for me. For instance if I run this on /etc using

-group root -o group shadow

I get only entries that are in groups lp or dip. If I switch
to dip, I get entries in lp and shadow.

Yes, I also tried it in tcsh just to be sure, and I tried it in
my home directory.
Post by Kenny McCormack
This dumps out every file. It should just dump out a few. Why?
Maybe some invisible junk characters in the command line?
Try typing it out afresh.

Is there direct proof in the output that the results are wrong? Are any
of the listed files in group foo or bar contrary to the query?
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @***@mstdn.ca
Christian Weisgerber
2024-12-27 22:37:26 UTC
Reply
Permalink
Post by Kenny McCormack
I'm trying to find all files in my home dir that are not in group foo or
group bar. Most of my files are in one or the other of these groups.
% find ~ -xdev \! \( -group foo -o -group bar \) -ls
Works for me. You can also de-morgan the expression

% find ~ -xdev \! -group foo \! -group bar -ls

but obviously that won't change whatever underlying problem you're
having.
--
Christian "naddy" Weisgerber ***@mips.inka.de
Kenny McCormack
2024-12-28 01:16:54 UTC
Reply
Permalink
Post by Christian Weisgerber
Post by Kenny McCormack
I'm trying to find all files in my home dir that are not in group foo or
group bar. Most of my files are in one or the other of these groups.
% find ~ -xdev \! \( -group foo -o -group bar \) -ls
Works for me.
OK - I've got this sorted now.

tl; dr: It works if you put in the correct numeric gid(s) rather than the
symbolic group names. So, I am not losing my mind, and the syntax is
correct.

Longer version: The system on which I am running this (not my system) is a
little bit misconfigured, such that even though both ls and find display
the group id of my files as "foo", and "foo" is defined in /etc/group as
having gid (say) 1234, in fact, my files are not in group 1234, but rather
in group (say) 5678.

So, bottom line, when you use the name "foo" in the command line, "find"
translates that to 1234 and looks for files not in group 1234 (which is
almost all of them) and so on...
--
I'll give him credit for one thing: He is (& will be) the most quotable President
ever. Books have been written about (GW) Bushisms, but Dubya's got nothing on Trump.

Tremendously wet - from the standpoint of water.
Lawrence D'Oliveiro
2024-12-28 02:04:51 UTC
Reply
Permalink
Post by Christian Weisgerber
You can also de-morgan the expression
First time I heard a reference to De Morgan’s theorems being used as a
verb. ;)

Does make it sound like you are removing something called “morgan” though,
doesn’t it ...
Kenny McCormack
2024-12-28 10:20:11 UTC
Reply
Permalink
Post by Christian Weisgerber
You can also de-morgan the expression
First time I heard a reference to De Morgans theorems being used as a
verb. ;)
Does make it sound like you are removing something called morgan though,
doesnt it ...
I think the word we're looking for here is: un-de-morgan.

That is, to translate the verbose but more understandable:

!foo and !bar

into:

! (foo or bar)

via application of De Morgan's law(s) would be to de-morgan it.

CW was suggesting the reverse operation.
--
People sleep peaceably in their beds at night only because rough
men stand ready to do violence on their behalf.

George Orwell
Salvador Mirzo
2024-12-28 17:35:15 UTC
Reply
Permalink
Post by Kenny McCormack
Post by Christian Weisgerber
You can also de-morgan the expression
First time I heard a reference to De Morgans theorems being used as a
verb. ;)
Does make it sound like you are removing something called morgan though,
doesnt it ...
I think the word we're looking for here is: un-de-morgan.
!foo and !bar
! (foo or bar)
via application of De Morgan's law(s) would be to de-morgan it.
CW was suggesting the reverse operation.
I'd suggest that to write

!(foo or bar)

is /to de-morgan/ the expression ``!foo and !bar'', while to rewrite
back as !(foo or bar) is /to morgan/ the expression.
Janis Papanagnou
2024-12-28 18:12:08 UTC
Reply
Permalink
Post by Salvador Mirzo
Post by Kenny McCormack
Post by Christian Weisgerber
You can also de-morgan the expression
First time I heard a reference to De Morgans theorems being used as a
verb. ;)
Does make it sound like you are removing something called morgan though,
doesnt it ...
I think the word we're looking for here is: un-de-morgan.
!foo and !bar
! (foo or bar)
via application of De Morgan's law(s) would be to de-morgan it.
CW was suggesting the reverse operation.
I'd suggest that to write
!(foo or bar)
is /to de-morgan/ the expression ``!foo and !bar'', while to rewrite
back as !(foo or bar) is /to morgan/ the expression.
I've ever always seen both directions as transformations according
to the laws of De Morgan (so neither would be en-morgan or de-morgan,
sort of).

In context of 'find' the '-and' form might be considered simpler due
to 'find's inherent 'and'-logic.

Janis
Salvador Mirzo
2024-12-30 21:15:46 UTC
Reply
Permalink
Post by Janis Papanagnou
Post by Salvador Mirzo
Post by Kenny McCormack
Post by Christian Weisgerber
You can also de-morgan the expression
First time I heard a reference to De Morgans theorems being used as a
verb. ;)
Does make it sound like you are removing something called morgan though,
doesnt it ...
I think the word we're looking for here is: un-de-morgan.
!foo and !bar
! (foo or bar)
via application of De Morgan's law(s) would be to de-morgan it.
CW was suggesting the reverse operation.
I'd suggest that to write
!(foo or bar)
is /to de-morgan/ the expression ``!foo and !bar'', while to rewrite
back as !(foo or bar) is /to morgan/ the expression.
I've ever always seen both directions as transformations according
to the laws of De Morgan (so neither would be en-morgan or de-morgan,
sort of).
We're defining directions here so that we can speak and look cool. We
can all pose as intellectuals. And people will have to look up the
morgan verb---unsuccessfully.
Post by Janis Papanagnou
In context of 'find' the '-and' form might be considered simpler due
to 'find's inherent 'and'-logic.
I think en-morgan should making something jump into the parentheses and
de-morgan should be the reverse. We should not be too logical. We
should prioritize how we sound and how our powerpoint presentations will
look like when we're presenting our style.
Lew Pitcher
2024-12-31 15:54:20 UTC
Reply
Permalink
On Mon, 30 Dec 2024 18:15:46 -0300, Salvador Mirzo wrote:

[snip]
Post by Salvador Mirzo
I think en-morgan should making something jump into the parentheses and
de-morgan should be the reverse.
As those specific laws of valid inference were named after Augustus De Morgan
(son of John De Morgan and Elizabeth Dodson), with "De Morgan" being Agustus'
surname, it is fitting to refer to them as "De Morgan's laws" or "De Morgan's
theorem"

I propose that the verb "DeMorgan" (as in "to DeMorgan an expression") be
used to represent the application of the normal form of "De Morgan's theorem",
and the verb "deDeMorgan" be used to represent the application of the inverse
of "DeMorgan".


Just my 10(binary) cents worth, of course :-)
--
Lew Pitcher
"In Skills We Trust"
Grant Taylor
2024-12-31 22:32:21 UTC
Reply
Permalink
Post by Lew Pitcher
I propose that the verb "DeMorgan" (as in "to DeMorgan an expression")
be used to represent the application of the normal form of "De
Morgan's theorem", and the verb "deDeMorgan" be used to represent
the application of the inverse of "DeMorgan".
I would suggest "un-DeMorgan" (hyphen optional) in order to avoid
conflict between the two pairs of "de" (case insensitive).
--
Grant. . . .
Salvador Mirzo
2025-01-01 02:28:31 UTC
Reply
Permalink
Post by Grant Taylor
Post by Lew Pitcher
I propose that the verb "DeMorgan" (as in "to DeMorgan an
expression") be used to represent the application of the normal form
of "De Morgan's theorem", and the verb "deDeMorgan" be used to
represent the application of the inverse of "DeMorgan".
I would suggest "un-DeMorgan" (hyphen optional) in order to avoid
conflict between the two pairs of "de" (case insensitive).
Well said---the world has enough conflicts; not to mention all the IRQ
conflicts I went through when running Windows 3.11 back in 19... I
forget.

Loading...