On Wed, Dec 28, 2011 at 04:31, aleksandergajewski < aleksandergajew...@gmail.com> wrote:
> Hi, i've just come across vim startstar symbol - here's note from vim > help: > > << CUT HERE >> > The usage of '*' is quite simple: It matches 0 or more characters. > In a > search pattern this would be ".*". Note that the "." is not used > for file > searching. > > '**' is more sophisticated: > - It ONLY matches directories. > - It matches up to 30 directories deep by default, so you can > use it to > search an entire directory tree > - The maximum number of levels matched can be given by appending > a number > to '**'. > Thus '/usr/**2' can match: > > /usr > /usr/include > /usr/include/sys > /usr/include/g++ > /usr/lib > /usr/lib/X11 > .... > < It does NOT match '/usr/include/g++/std' as this would be > three > levels. > The allowed number range is 0 ('**0' is removed) to 100 > If the given number is smaller than 0 it defaults to 30, if > it's > bigger than 100 th<< CUT HERE >>en 100 is used. The system > also has a limit on the > path length, usually 256 or 1024 bytes. > - '**' can only be at the end of the path or be followed by a > path > separator or by a number and a path separator. > << CUT HERE >> > > Every time I wanted to use recursive search in bash, i wrote simple > script, or did manually (eg. ls */*.txt; ls */*/*.txt etc.), then I > found 'find + xargs', but in fact '**' would be sufficient for my > needs (and it seems to be more useful in most cases) > > Here is my question: why there is no such thing in bash? Is there any > compatibility issue, which makes it difficult/impossible to introduce > in bash? > Bash 4.0 added a new shopt option `globstar'. ... When enabled, the globbing code treats `**' specially -- it matches all directories (and files within them, when appropriate) recursively. Is that what you want?