6

According to legend, in the early days what we now call "globbing" (i.e. using expressions like e.g. *.c, ./*.p?) was supported by one certain program /etc/glob, whose name in turn derived from "global command"...

I don't know about you, but for me, learning that "glob", "globbing", etc. comes from "global command" is about as illuminating as learning that it came from "globothymic pylotensity"...

What on earth is a "global command"?

kjo
  • 14,779
  • 25
  • 69
  • 109

1 Answers1

7

Global is used here the same way it is in regular expressions (/g = global), i.e., it means "apply this command to everything applicable", not just the first possible instance.

Hopefully that "everything" vs. "something" applicability makes more sense of the "global" adjective. To explain a bit further, consider you have 3 files, a.txt, b.txt, and c.txt. If you issue a command with globbing, it will apply to all three because it applies to everything globally (a redundant phrase), not just the first thing that matches the pattern according to some (e.g. alphabetical) order.

goldilocks
  • 86,451
  • 30
  • 200
  • 258
  • Regular expressions seem to be a rich source of Unix conundrums, including the one that has probably scared away, or at least mystified, the most people: `grep`... – kjo Sep 06 '13 at 13:17
  • I think one of the issues with grep is that by default it uses POSIX style regexps, which have some subtle and not so subtle differences from the nowadays more common PCRE ("Perl compatible regular expression") style. No doubt this causes a lot of confusion for people when learning online! – goldilocks Sep 06 '13 at 13:25
  • well, that too, but I was just alluding to the sheer opacity of the name `grep`. Hmmmm, "sheer opacity": there's an oxymoron for you! – kjo Sep 06 '13 at 14:47
  • 2
    Might be stating the obvious, ...from the wikipedia page on [grep](http://en.wikipedia.org/wiki/Grep) ... the text editor [ed](http://en.wikipedia.org/wiki/Ed_(text_editor)) had a command, g/re/p (globally search a regular expression and print). Manu of the idoms in `sed`, `perl`, and `awk` seem to echo from this tool, which makes sense given the lineage. – slm Sep 06 '13 at 18:38
  • @goldilocks I guess that's the best answer that could exist. It's still a dumb name. I will continue to think of it as related globules coming together, a la _Terminator 2_. – Scott Stafford Sep 13 '18 at 13:51
  • Given that there were many ed variants like `v/re/p` and `g/re/d`, you should probably be glad that those became grep options and not separate commands. Before the head command, `sed -11q` was a familiar alternative too. – Paul_Pedant Feb 27 '20 at 23:46