scowles | 5 Sep 03:06

filename pattern search in dynamically specified list of directories


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.

i am using zsh cvs sources pulled 22 august 2008 and built under ubuntu 7.10 
on an intel platform; the displayed ZSH_VERSION is 4.3.6-dev-0.

the relevant, generalized code snippet i am using is shown here.  the job 
searches for dot files as well as non-dot files.

if anyone can offer suggestions for a simpler, cleaner one-liner, i'd very 
much appreciate the suggestions.

-----------------
#!/usr/local/bin/zsh

# set appropriate options.
setopt GLOB
setopt EXTENDED_GLOB
setopt NONULL_GLOB
setopt nonomatch

# create the test environment.
[[ ! -d tmp ]] && { mkdir tmp ; }
[[ ! -d tmp/subdir ]] && { mkdir tmp/subdir ; }
touch tmp/a001 tmp/b002 tmp/c-no-digits
touch tmp/subdir/one0011 tmp/subdir/two-no-digits

# the command to dynamically generate the desired list of directories.
(Continue reading)

Bart Schaefer | 5 Sep 17:31

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:

(Continue reading)


Gmane