Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.arch Subject: Re: shell architecture (to glob or not to glob) Message-ID: <1991Feb14.024803.1252@Think.COM> Date: 14 Feb 91 02:48:03 GMT References: <378@bria> Sender: news@Think.COM Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 47 In article kenw@skyler.arc.ab.ca (Ken Wallewein) writes: > Ever notice that all Unix commands that support globbing only allow it at >the end of the command, and only allow one (possibly list) argument to be >globbed? I never noticed that, because it isn't true. First of all, there's no such thing as "all Unix commands that support globbing", since the globbing is independent of the command. More to the point, though, you can glob as many arguments as you want, and they can be anywhere on the line. For instance, I've done things like find foo/* bar/* -name "*frob*" -print > That's why you can't say > > mv here/* there/* You can say it, but it won't do what you probably hope. The wildcards are expanded, and then all the pathnames are passed to the mv command. The command doesn't see the original wildcards, so it can't treat them specially. The above command is exactly equivalent to mv here/file1 here/file2 here/file3 there/filea there/fileb Your reference to "only at the end of the command" is probably is probably confusion about the fact that most Unix commands have syntax of the form command -options files This is merely a common syntax convention; it makes it a little easier to parse the arguments, because it can stop processing options as soon as it sees the first argument that doesn't begin with "-", and then simply loop over the remaining arguments. The find command is a good counterexample. Another example of a command where the globbed argument is likely not to be the last one is mv: one of its allowed syntaxes is mv -options file file file ... directory (this moves all the files into the directory). It is quite common to use wildcards in the file arguments, e.g. mv here/* there/* nowhere -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar