From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9583 invoked by alias); 18 Mar 2014 21:42:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18623 Received: (qmail 11516 invoked from network); 18 Mar 2014 21:42:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140318144230.ZM15739@torch.brasslantern.com> Date: Tue, 18 Mar 2014 14:42:30 -0700 In-reply-to: <20140318202309.4d830a8b@pws-pc.ntlworld.com> Comments: In reply to Peter Stephenson "Re: Compare two (or more) filenames and return what is common between them" (Mar 18, 8:23pm) References: <20140318202309.4d830a8b@pws-pc.ntlworld.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh-Users List Subject: Re: Compare two (or more) filenames and return what is common between them MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Mar 18, 8:23pm, Peter Stephenson wrote: } Subject: Re: Compare two (or more) filenames and return what is common bet } } On Tue, 18 Mar 2014 03:05:27 -0400 } TJ Luoma wrote: } > What I am trying to do: } > } > Given a folder/directory full of files (and, possibly, some existing } > folders/directories), I want to create folders which will group files } > with similar files names, but which will leave folders alone. } } I'm still not quite sure after reading your description what it is you } want I suspect he wants something like this: http://en.wikipedia.org/wiki/Approximate_string_matching Zsh has such a function internally for "spelling" correction, but it is actually based on correcting for typographical mistakes on a QWERTY keyboard more than on traditional substring similarity. You could also try something with the (#a) glob qualifier (approximate matching) but it's VERY expensive for strings as long as some of your example file names and is entirely impossible to interrupt once it is started ("kill -9" territory).