What is file globbing?

Globbing is the * and ? and some other pattern matchers you may be familiar with. Globbing interprets the standard wild card characters * and ?, character lists in square brackets, and certain other special characters (such as ^ for negating the sense of a match). When the shell sees a glob, it will perform … Read more

Glob / minimatch: how to gulp.src() everything, then exclude folder but keep one file in it

This seems to work: gulp.src([ baseDir + ‘/**’, // Include all ‘!’ + baseDir + ‘/excl1{,/**}’, // Exclude excl1 dir ‘!’ + baseDir + ‘/excl2/**/!(.gitignore)’, // Exclude excl2 dir, except .gitignore ], { dot: true }); Excluding single file from glob match was tricky because there’s no similar examples in minimatch docs. https://github.com/isaacs/minimatch “If the … Read more

how to `git ls-files` for just one directory level.

(late edit for a feature added in Git 1.8.5, after the question and answer were written:) Git’s pathspecs ordinarily match * with any path substring, including / separators, but you can use shell pathname-matching conventions by adding a magic :(glob) prefix. So to list just the files in the current directory, git ls-files ‘:(glob)*’ # … Read more

How to loop through all the files located under a certain path in zsh?

There is no need to use find. You could try the following: for file in /path/to/directory/**/*(.); do echo $file; done or for file in /path/to/directory/**/*(.); echo $file the ** pattern matches multiple directories recursively. So a/**/b matches any b somewhere below a. It is essentially matches the list find a -name b produces. (.) is … Read more

Assign results of globbing to a variable in Bash

The problem is that the glob will only expand if the file “rotten_eggs” exists, because it is included in the glob pattern. You should use an array. FOO=( ryan/smells-* ) touch “${FOO[@]/%//rotten_eggs}” The FOO array contains everything matched by the glob. The expansion using % appends /rotten_eggs to each element.

Simple glob in C++ on unix system?

I have that in my gist. I created a stl wrapper around glob so that it returns vector of string and take care of freeing glob result. Not exactly very efficient but this code is a little more readable and some would say easier to use. #include <glob.h> // glob(), globfree() #include <string.h> // memset() … Read more

glob and bracket characters (‘[]’)

The brackets in glob are used for character classes (e.g. [a-z] will match lowercase letters). You can put each bracket in a character class to force them being matched: path1 = “/Users/smcho/Desktop/bracket/[[]10,20[]]” [[] is a character class containing only the character [, and []] is a character class containing only the character ] (the closing … Read more

tech