Case-insensitive Glob on zsh/bash

ZSH: $ unsetopt CASE_GLOB Or, if you don’t want to enable case-insensitive globbing in general, you can activate it for only the varying part: $ print -l (#i)(somelongstring)* This will match any file that starts with “somelongstring” (in any combination of lower/upper case). The case-insensitive flag applies for everything between the parentheses and can be … Read more

How to assign a glob expression to a variable in a Bash script?

I think it is the order of expansions: The order of expansions is: brace expansion, tilde expansion, parameter, variable and arithmetic expansion and command substitution (done in a left-to-right fashion), word splitting, and pathname expansion. So if your variable is substituted, brace expansion doesn’t take place anymore. This works for me: eval ls $dirs Be … Read more

php glob – scan in subfolders for a file

There are 2 ways. Use glob to do recursive search: <?php // Does not support flag GLOB_BRACE function rglob($pattern, $flags = 0) { $files = glob($pattern, $flags); foreach (glob(dirname($pattern).’/*’, GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { $files = array_merge( [], …[$files, rglob($dir . “/” . basename($pattern), $flags)] ); } return $files; } // usage: to find the test.zip … Read more

node.js glob pattern for excluding multiple files

I suppose it’s not actual anymore but I got stuck with the same question and found an answer. This can be done using only glob module. We need to use options as a second parameter to glob function glob(‘pattern’, {options}, cb) There is an options.ignore pattern for your needs. var glob = require(‘glob’); glob(“**/*”,{“ignore”:[‘index.html’, ‘js’, … Read more

glob pattern matching in .NET

I like my code a little more semantic, so I wrote this extension method: using System.Text.RegularExpressions; namespace Whatever { public static class StringExtensions { /// <summary> /// Compares the string against a given pattern. /// </summary> /// <param name=”str”>The string.</param> /// <param name=”pattern”>The pattern to match, where “*” means any sequence of characters, and “?” … Read more

git: How do I recursively add all files in a directory subtree that match a glob pattern?

It’s a bug in the documentation. Quote the asterisk with $ git add documentation/\*.screen or $ git add ‘documentation/*.screen’ to get the behavior you want. If instead you want to add files in the current directory only, use $ git add *.screen UPDATE: I submitted a patch that corrects the issue, now fixed as of … Read more

tech