Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Compare two (or more) filenames and return what is common between them



On Fri, 21 Mar 2014 15:02:52 -0400
TJ Luoma <luomat@xxxxxxxxx> wrote:
> So here are the steps simpler version of what I’d like to do (which, I
> realize, might not be possible to do in a shell script):
> 
> 1. Find all of the files (not directories) in a given directory (that
> directory would probably be “$@“ in most cases)
> 
> 2. Type the first ~4 letters of each filename
> 
> 3. Emulate {tab} for completion matching
> 
> 4. Create a directory based on the output> 
> Thanks!
> 
> TjL
 from step #3
> 
> 5. Move whatever files matched step #3 into the folder created in step 4
> 
> 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 worried 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



Messages sorted by: Reverse Date, Date, Thread, Author