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

Re: Glob for specific length?



On Mon, 22 Nov 2010, Aaron Davies wrote:

Is there a glob for files with names of e.g. exactly thirty characters? sort of the equiv of /^.{30}$/

I don't know whether there's a more concise one, but this works to `ls` the ones that match:

ls -l *(e:'[[ $#REPLY == 30 ]] || reply=()':)

You could also wrap the expression there into a function:

globlen() { [[ $#REPLY == $GLOBLEN ]] || reply=() }
GLOBLEN=30
ls -l *(+globlen)

More info:

man zshall | less +/estring

--
Best,
Ben



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