From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5930 invoked by alias); 21 Mar 2014 19:39:27 -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: 18653 Received: (qmail 2652 invoked from network); 21 Mar 2014 19:39:20 -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 X-Originating-IP: [86.6.157.246] X-Spam: 0 X-Authority: v=2.1 cv=VLBTnr/X c=1 sm=1 tr=0 a=BvYiZ/UW0Fmn8Wufq9dPrg==:117 a=BvYiZ/UW0Fmn8Wufq9dPrg==:17 a=NLZqzBF-AAAA:8 a=7s3Jj7Ix0b0A:10 a=uObrxnre4hsA:10 a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=O8O4rOBv6lTPT5Cu9b8A:9 a=QEXdDO2ut3YA:10 a=MSl-tDqOz04A:10 Date: Fri, 21 Mar 2014 19:39:15 +0000 From: Peter Stephenson To: Zsh-Users List Subject: Re: Compare two (or more) filenames and return what is common between them Message-ID: <20140321193915.481066f3@pws-pc.ntlworld.com> In-Reply-To: References: <20140318202309.4d830a8b@pws-pc.ntlworld.com> <140318144230.ZM15739@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 21 Mar 2014 15:02:52 -0400 TJ Luoma wrote: > So here are the steps simpler version of what I=E2=80=99d like to do (whi= ch, I > realize, might not be possible to do in a shell script): >=20 > 1. Find all of the files (not directories) in a given directory (that > directory would probably be =E2=80=9C$@=E2=80=9C in most cases) >=20 > 2. Type the first ~4 letters of each filename >=20 > 3. Emulate {tab} for completion matching >=20 > 4. Create a directory based on the output>=20 > Thanks! >=20 > TjL from step #3 >=20 > 5. Move whatever files matched step #3 into the folder created in step 4 >=20 > Is that more clear and/or possible? No, that's much harder! Hooking into completion is difficult. However, it sounds like you're saying you'd be happy with collecting files that happen to have any prefix in common, so you're not actually worr= ied about completion, just about common prefixes. That's probably simpler than what I implemented, where I required the common prefixes to be space delimited. It's different in that you're now saying you'd like to group by the shortest common string, whereas I've looked for the longest common string first. pws