From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13218 invoked from network); 30 May 2022 08:16:11 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 30 May 2022 08:16:11 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 8C237421F0; Mon, 30 May 2022 18:16:09 +1000 (AEST) Received: from relay05.pair.com (relay05.pair.com [216.92.24.67]) by minnie.tuhs.org (Postfix) with ESMTPS id 33015421EA for ; Mon, 30 May 2022 18:16:06 +1000 (AEST) Received: from orac.inputplus.co.uk (unknown [84.51.159.244]) by relay05.pair.com (Postfix) with ESMTP id 5B4E11A2B7A for ; Mon, 30 May 2022 04:16:05 -0400 (EDT) Received: from orac.inputplus.co.uk (orac.inputplus.co.uk [IPv6:::1]) by orac.inputplus.co.uk (Postfix) with ESMTP id A9FBF21F8A for ; Mon, 30 May 2022 09:16:04 +0100 (BST) To: Computer Old Farts Followers From: Ralph Corderoy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit In-reply-to: References: Date: Mon, 30 May 2022 09:16:04 +0100 Message-Id: <20220530081604.A9FBF21F8A@orac.inputplus.co.uk> Message-ID-Hash: 44KFKSEEHJVBWQSHBRDY3B4N3TWKW7HC X-Message-ID-Hash: 44KFKSEEHJVBWQSHBRDY3B4N3TWKW7HC X-MailFrom: ralph@inputplus.co.uk X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [COFF] Re: Grep has gone overboard List-Id: Computer Old Farts Forum Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Hi Bakul, > You can write a program to generate all permutations and use that as > your regexp. For example abc maps to abc|acb|bac|bca|cab|cba. Being lazy, I tend to use a shell's brace expansion and then whittle it down to generate permutations. I keep thinking it's surprising there's no Bell Labs program to produce them given there's things like factor(1). The brace expansion is wasteful as it's going from n**l down to n! and it can result in the old bash here not responding to SIGINT for a while if it's producing gazillions. $ printf '%s\n' {b,a,d,u,g,l,y}{b,a,d,u,g,l,y}{b,a,d,u,g,l,y}\ > {b,a,d,u,g,l,y}{b,a,d,u,g,l,y}{b,a,d,u,g,l,y}{b,a,d,u,g,l,y} | > egrep -v '(.).*\1' | > fgrep -x -f - /usr/share/dict/words ladybug $ -- Cheers, Ralph.