Globbing refers to the operation that expands a wildcard pattern into the list of pathnames matching the pattern. In its current form it dates back to Version 6 Unix released in 1975, and before that it existed as a separate program, /etc/glob
, that supplied information to the command for execution. Nowadays, globbing is implemented in all types of programming languages including Java, Ruby, PHP, Python, etc.
I first heard the term used in a Dale Sande talk at Sass Conf. And, to be perfectly honest, I had no idea what he was talking about.
He was discussing a Ruby gem for Sass called Sass-globbing made by Compass creator Chris Eppstein. The gem lets you import multiple files using a single @import statement. A Sass-globbing import statement might look like @import 'modules/*';
. The glob, or global command, refers to the operation that matches all content within the modules
directory and lists them out as pathnames, in this case to import into a stylesheet. The asterisk (*) is the wildcard that tells the pattern to match all content within the modules
directory.
I didn’t realize it at the time, but I was using globbing every time I was working from the command line. From batch FFmpeg conversions like for i in *.wav; do ffmpeg ...
to general Command Prompt directory listings like DIR Users*
to Ruby scripts like ruby watcher.rb **/*.scss
.
Globbing is a pretty powerful operation that if you aren’t using yet, you should get familiar with as soon as possible. Here is a good starting point for learning more about globbing, as well as the obligatory link to the glob (programming) Wikipedia entry. Have fun!
Leave a Reply