3

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.

1 Answer 1

4

With zsh:

print -rl -- ./**/*(.DoN)
4
  • That's great. Thank you. What why not **/*(.DN)?
    – kjo
    Commented Nov 23, 2016 at 18:27
  • 1
    @kjo: yes, realize it recently, edited.
    – cuonglm
    Commented Nov 23, 2016 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. Commented Nov 23, 2016 at 18:34
  • @StéphaneChazelas: Fair point, updated.
    – cuonglm
    Commented Nov 23, 2016 at 19:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .