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

How to implement glob in C#

/// <summary> /// return a list of files that matches some wildcard pattern, e.g. /// C:\p4\software\dotnet\tools\*\*.sln to get all tool solution files /// </summary> /// <param name=”glob”>pattern to match</param> /// <returns>all matching paths</returns> public static IEnumerable<string> Glob(string glob) { foreach (string path in Glob(PathHead(glob) + DirSep, PathTail(glob))) yield return path; } /// <summary> /// uses … Read more

grunt (minimatch/glob) folder exclusion

In the currently-in-development version 0.4.0a, the grunt.file.expand method now supports exclusions, and does so in an arguably less complex way than the underlying minimatch matching library. This is possible because grunt.file.expand accepts multiple patterns (whereas minimatch only accepts one). From the grunt.file.expand documentation: This method accepts either comma separated wildcard patterns or an array of … Read more

How to count the number of files in a directory using Python

os.listdir() will be slightly more efficient than using glob.glob. To test if a filename is an ordinary file (and not a directory or other entity), use os.path.isfile(): import os, os.path # simple version for working with CWD print len([name for name in os.listdir(‘.’) if os.path.isfile(name)]) # path joining version for other paths DIR = ‘/tmp’ … Read more

What is the ** glob character?

It’s almost the same as the single asterisk but may consist of multiple directory levels. In other words, while /x/*/y will match entries like: /x/a/y /x/b/y and so on (with only one directory level in the wildcard section), the double asterisk /x/**/y will also match things like: /x/any/number/of/levels/y with the concept of “any number of … Read more

glob exclude pattern

The pattern rules for glob are not regular expressions. Instead, they follow standard Unix path expansion rules. There are only a few special characters: two different wild-cards, and character ranges are supported [from pymotw: glob – Filename pattern matching]. So you can exclude some files with patterns. For example to exclude manifests files (files starting … Read more

PHP get file listing including sub directories

from glob example if ( ! function_exists(‘glob_recursive’)) { // Does not support flag GLOB_BRACE function glob_recursive($pattern, $flags = 0) { $files = glob($pattern, $flags); foreach (glob(dirname($pattern).’/*’, GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { $files = array_merge($files, glob_recursive($dir.”https://stackoverflow.com/”.basename($pattern), $flags)); } return $files; } }

What are the differences between glob-style patterns and regular expressions?

Traditional glob wildcards support a very narrow set of metacharacters — * is “anything”, ? is an arbitrary single character; Bourne shell also supports [a-z123] for a single character out of a set of alternatives, and [!x-z789] any one except those listed. Regex obviously is much richer, supporting repetitions, and (in ERE) alternation and specific … Read more