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

Re: filename pattern search in dynamically specified list of directories



On Sep 4,  6:07pm, scowles wrote:
} 
} i am currently using the following code to identify all files with X
} or greater number of digits in the filenames. the list of directories
} in which to do the recursive search is dynamically generated.

Answering that question rather than attempting to reverse-engineer the
parameter expansion you ended up with:

Files with any number of digits anywhere in the file name:  *<->*
Remove one or more of the stars if you want digits only, or only at
one end or the other.

List of directories:  dirs=( $(your command here) )

List of files having digits in those directories:  $^dirs/*<->*(N)

The (N) is in case some of the directories have no matching files.

To avoid the "dirs" variable:  ${=^$(your command here)}/*<->*(N)

Replace "=" with (f) if your command prints separate lines and your
directory names might have spaces in them.

Replace <-> with [[:digit:]](#c2,) to get at least two digits, etc.

****

Aside to PWS if he's reading:

Strange bug.  *<->(#c3,)* will match files having only two digits.
There's some bug with repeating the <-> match.

torch% print *<->(#c1,)*
123xyz a001 b002 c3 d45
torch% print *<->(#c1,)*        
123xyz a001 b002 c3 d45
torch% print *<->(#c2,)*
123xyz a001 b002 d45
torch% print *<->(#c3,)*
123xyz a001 b002 d45
torch% print *<->(#c4,)*
123xyz a001 b002
torch% print *<->(#c5,)*
123xyz a001 b002
torch% print *<->(#c6,)*
123xyz a001 b002
torch% print *<->(#c7,)*
123xyz a001 b002
torch% print *<->(#c8,)*
zsh: no matches found: *<->(#c8,)*



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