2

I'm looking for the simplest glob expression that will always expand to the same (possibly empty) set of files as that listed by

find . -type f

...and never result in a no matches found error, irrespective of the contents of ..

I've tried many variations of ./{**,.**}/{*,.*}(.N) that fail under one situation or another. (For example, ./{**,.**}/{*,.*}(.N) fails to match ./.dir0/.dir1/.file0.)

EDIT: Assume that extendedglob is on, and that nullglob is off.

3

With zsh:

print -rl -- ./**/*(.DoN)
  • That's great. Thank you. What why not **/*(.DN)? – kjo Nov 23 '16 at 18:27
  • 1
    @kjo: yes, realize it recently, edited. – cuonglm Nov 23 '16 at 18:28
  • 1
    Strictly speaking, that would be more like ./**/*(.DoN) to add the ./ prefix to each file and not sort the files (find internally may sort by inode number to optimise performance on rotational storage, so you may still find differences in the order). If there's no matching file with the N flag, print will still print an empty line. You may want to omit that flag which makes for a more pertinent outcome in that case. – Stéphane Chazelas Nov 23 '16 at 18:34
  • @StéphaneChazelas: Fair point, updated. – cuonglm Nov 23 '16 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.