dylanaraps / pure-sh-bible

📖 A collection of pure POSIX sh alternatives to external processes.
MIT License
6.44k stars 280 forks source link

Globbing hidden files #12

Open ghost opened 4 years ago

ghost commented 4 years ago

Examples that use globbing such as Count files or directories in directory don't take into account files starting with a dot.

defdefred commented 4 years ago

exclude . & .. $ count .[^.] ..? * 39

include all files

$ count . 41

chambln commented 4 years ago

What is ..?* supposed to expand to? Is that not equivalent to ..*?

$ ls -a
.  ..  .hidden  visible
$ echo * .*
visible . .. .hidden
$ echo * .[^.]*
visible .hidden
chambln commented 4 years ago

Oh, I see: ..?* covers files that start with two dots (except ..). Very nice!

$ ls -a
.  ..  ..doubledot  .hidden  visible
$ echo * .*
visible . .. ..doubledot .hidden
$ echo * .[^.]* ..?*
visible .hidden ..doubledot
chambln commented 4 years ago

@dylanaraps Is this worth adding to the book somewhere? Either as a note in 'Count files or directories in directory' or a section dedicated to globbing tricks?