• syntax of "find" - am I losing my mind?

    From Kenny McCormack@21:1/5 to All on Fri Dec 27 20:08:53 2024
    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 <kaz@kylheku.com> in comp.lang.c

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Kenny McCormack on Fri Dec 27 21:57:52 2024
    On 2024-12-27, Kenny McCormack <gazelle@shell.xmission.com> wrote:
    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

    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.

    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: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From marrgol@21:1/5 to All on Fri Dec 27 22:39:14 2024
    On 2024-12-27 at 21:08 Kenny McCormack wrote:
    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).

    $ find ~ -xdev -not -group foo -not -group bar -ls

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From marrgol@21:1/5 to All on Fri Dec 27 22:59:30 2024
    On 2024-12-27 at 22:39 marrgol wrote:
    On 2024-12-27 at 21:08 Kenny McCormack wrote:
    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).

    $ 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Wayne@21:1/5 to Kenny McCormack on Fri Dec 27 16:29:25 2024
    The "-ls" doesn't work as yoiu expect. Try something like -print or
    -printf instead.

    --
    Wayne

    On 12/27/2024 3:08 PM, Kenny McCormack wrote:
    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).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Weisgerber@21:1/5 to Kenny McCormack on Fri Dec 27 22:37:26 2024
    On 2024-12-27, Kenny McCormack <gazelle@shell.xmission.com> wrote:

    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

    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 naddy@mips.inka.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to naddy@mips.inka.de on Sat Dec 28 01:16:54 2024
    In article <slrnvmub16.22so.naddy@lorvorc.mips.inka.de>,
    Christian Weisgerber <naddy@mips.inka.de> wrote:
    On 2024-12-27, Kenny McCormack <gazelle@shell.xmission.com> wrote:

    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

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Christian Weisgerber on Sat Dec 28 02:04:51 2024
    On Fri, 27 Dec 2024 22:37:26 -0000 (UTC), Christian Weisgerber wrote:

    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 ...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)