From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 5B17C23B5F for ; Sun, 21 Jan 2024 20:10:37 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1705864237; b=W1FHvlbIiwUUqCbFCqDE3X6TDkboMWYICU5R+iHTKNixiqB5POJ8tsib0cY8KPc+4C9uGTh2Gr VFVdjFf6hlXujF80kllyvisYjQSRdJIapK6WCh5ChNVMETpeh9ihIm6QMITNE2sJKliqlfATHL c0brQzis4xcGQJFva/0l6NxjrGgWX54qAhnl43AMS7G8fj2FarrBRrdIMoDR/4QUvVEUqGIXnw tTEiFyYanEdp/bBncf+TqWAT26aqfKHI290lcThEjTkfeVm8nZqqt2o6EKZ5qTNKasOFpL+eW6 k9lrdEOpGeZLMAeb6GwhEETG8dXDHmlEz2fXJ9OxY3Vsng==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f43.google.com) smtp.remote-ip=209.85.218.43; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1705864237; bh=ey1xsR+gkwzqHEsujsQIqaW7/aOyDJJGe9BBpE+HR9U=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=qq7i1mxAowgB8KWlVAbST+JlsOdakG383VG+MLpjn40pzsSvnlI1jv1DnKnPi0oqDiZzLSjzTB ZY5AhNS6K5eEUVFwRUbb/K1IaTJQ86N6odlLRFJDtah/bDQj3T3LsOFdLN6ro7JaaFeFNGjooB ETP8fV7JfYpH3EVHF5ft0Rr6ySOJKlC4mgNcFPU24HSxV5Gq11LAN7DhlPvurY8BB8w8z635mn zVAXTf2ElqwJsAI4Ihi4UDF763tAvnoh3axXV2WRpUGdRvsO93KxbUgP0OwArRFPWovLwmWSze u1uT/natG6k1sySyZWfGqFHTBFCt5ThVFnE48lsbXIcOKA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=c/JR8JMS8rK+3XuJL+4RYWUNx8fjSLPKtNuUmYOXm9g=; b=H8dISRH6qamT5l25jhpG5B0kb/ xZmGKrlya6r7uWOiVIqscHGMeseJj0wLApkX0eKJ3ssKz9UhvFHj2fEinmcnLFMwtMRQ57Zo00P9f 0Bx3Cju4wdeQA0HVTE63l2ura0U0F3lc1Azr5WUrsT6wE2p/Je6Zy9Of4tX+JbgiCuOIavu2iF3ZS FVEuAoTObESjjbACuUrms+Kssd1tGlWUdnkK9uRbO+JYlTzFV3crYL/3vQVbazFMVWswlQLXebvHh MWL+nzu7a8C8FYFx4tLCydkbC9q0vL6Lv82CfS2VVmveg8qddHILK1T162aEzxKeTmRzIhjUvTCua WbvvoyWA==; Received: by zero.zsh.org with local id 1rRdDJ-0000Ca-26; Sun, 21 Jan 2024 19:10:37 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f43.google.com) smtp.remote-ip=209.85.218.43; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f43.google.com ([209.85.218.43]:59788) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rRdCn-000PSJ-7e; Sun, 21 Jan 2024 19:10:06 +0000 Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a27733ae1dfso247035566b.3 for ; Sun, 21 Jan 2024 11:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1705864204; x=1706469004; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=c/JR8JMS8rK+3XuJL+4RYWUNx8fjSLPKtNuUmYOXm9g=; b=HXWzgsoFaHsKrXZMN0TTGsTWAmFNezpGLzyAjtnUhp+0aC3zArP3rg1S8pJA9J0bcA Q3sAIxmJBZwTnjVgdduU9XWVr6niGuFPgHv6tdnfdP6ov7j3+QZCGzROsXomwglI1MWm d7mnG4UXxzmxwv2NJAJ4j1y6RKjIAjQq+btRuCm85E1ybmPL2o1HQj5qzcIHwJ8NdBNP zOmC4VyW6zOrTqE5q0H82OOtTr8/qHwDxJF72nn6ArEy24T9osAjwS6fwd3ACx/caLPG a53vyZQvgxg9DZD8uJ9eMwiw4EBUzoUb2EnuDglqVviRVfoMYJ07vLm1l3IH06lkBWyc 4URw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705864204; x=1706469004; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c/JR8JMS8rK+3XuJL+4RYWUNx8fjSLPKtNuUmYOXm9g=; b=sEFc4tBBemrrUnrtY8cdYFLqTKEiUeXKlMRm7dFvof5904p77n3//zNC9By5dy89tJ 9IRLzVww+3ZpZGbt0R1ghba+IoUO4uiKsauMPaPXzZx2fJvdJGVuNRI85pM5hu57OAtH ZO+Lo1vMzLVxtVmTYzP+0dkZsRXcZPr6nr5VtlVCqogE94TpX7PjVfB4jjJaIgThrumr hSZ+MCCEF6BUUqvQ3nf54wYCIYu9VZFPirAflQRO6ZY/W/rMnaJuvVJtxlBPBEtPozbp 8zk53PfELxEUcpVFZOSPdFRjjfn8uExWcWFVc1pZMscLQyNHNE6RwsG+0gsx8JdPhvId mjHA== X-Gm-Message-State: AOJu0YxuKnjBH0aLhoTkGA1m7FYFXCg1NQ4+TQOXGzK/RhmUGk79mUe9 h9n0+vxOG/GVDDt/tCLd7Tx1dgC+YCTCANcMRRcUaFVLfzGzSl/mfns9qDD6pAknHxruT1nJq7e 1ihaqmnnowflRyj23F8qTcObsgwUUvtlSSq4Oyf8nB5gYlkusVw== X-Google-Smtp-Source: AGHT+IFP0J9voUCkaPuSVpPCLogec0vjJd9Td8RuRPM6ijOi1gGPeLPLIncZliA4HA4Z/REx3b3jy6ydTZmzJd9VMrI= X-Received: by 2002:a17:907:c314:b0:a28:f6a2:ca7a with SMTP id tl20-20020a170907c31400b00a28f6a2ca7amr1408032ejc.178.1705864204196; Sun, 21 Jan 2024 11:10:04 -0800 (PST) MIME-Version: 1.0 References: <62da1cec-bcc9-49ed-8f5f-ad428fdd3f20@eastlink.ca> In-Reply-To: <62da1cec-bcc9-49ed-8f5f-ad428fdd3f20@eastlink.ca> From: Bart Schaefer Date: Sun, 21 Jan 2024 11:09:52 -0800 Message-ID: Subject: Re: /proc slows % echo /**/*/etc/r*(/N) To: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29534 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Sun, Jan 21, 2024 at 9:19=E2=80=AFAM Ray Andrews wrote: > > I used to do this kind of thing without any problems: > > % echo /**/*/etc/r*(/N) > > ... but just trying it, zsh labors for close to an hour, then spits out > countless pages of: > > /proc/9/root/etc/rc0.d /proc/9/root/etc/rc1.d /proc/9/root/etc/rc2.d Why /**/*/ rather than just /**/ ? The extra /*/ there will expand symbolic links, which are normally skipped by /**/. It's not otherwise adding anything to the traversal. /proc/9 is for PID 9 and /proc/9/root is a symbolic link to the root directory for that process, so by expanding that you're traversing the whole filesystem again, which takes you back to /proc/ again, and so on for every PID until zsh gives up (probably because it can't allocate any more memory). > ... I'm wondering why /proc wasn't a problem previously I suspect previously you weren't adding that extra /*/. What do you mean for that to accomplish? > and if there's > anything I can do to filter it out of the search -- probably all the > Linux 'system' directories too. I recall that there's some test, > something in permissions, some flag -- that identifies these > not-quite-real directories -- zsh knows who they are. There's no glob qualifier for that, if that's what you mean. As it happens, those directories always appear to be empty, so you can find them with /*(/L0) but you can't use glob qualifiers in the middle of a longer pattern (only at the end) so that won't help with your recursive search. > I know the tilde is used to make exceptions: > but I can't get the syntax correct with the above. That syntax is applied as a string match after the glob has already expanded, so putting it at the end like this ... > % echo /**/*/etc/r*~/proc*(/N) ... is just going to waste even more time. As Mark suggested, there are exclusion patterns you can apply, but /**/ is still going to search the whole filesystem at least once, possibly crossing mount points into other filesystems if you have anything NFS or similarly remote mounted. Without trying it, which I'm not going to do, I think the answer to your specific question might be: echo /**/^(proc|sys)/etc/r*(N) But that might actually miss /etc/r* because it would be looking for /etc/etc/. There's no syntax for excluding things specifically from the ** pattern.