On Tue, Apr 16, 2019 at 09:52:57AM +1000, Cameron Simpson wrote:
> On 15Apr2019 11:23, felixs <besteck...@gmail.com> wrote:
> > Thanks, Cameron. Some coments go in between your comments.
> 
> As they should :-)
> 
> > > If you go:
> > > 
> > >  sed ... <path/tospoolfile/*
> > > 
> > > and that does not match a _single_ file, then the shell will not do the
> > > redirection at all (because it can't) and sed doesn't run. This isn't a 
> > > bug
> > > in sed or the shell, just that you've asked for something nonsensical.
> > 
> > Well, I simply tried to use the catch-all parameter, which cannot be used
> > in this case. But it is accepted when having no redirection.
> 
> These are 2 different things. And I misspoke anyway.
> 
> Globbing is used to construct command line arguments. But a redirection is
> not a command line parameter - it is only subject to parameter substitution
> - $blah.

Ok, got it. Globbing = filename expansion, as to the Bash Reference
Manual. Just to understand: the "${file}.out" in the variable assignment 
Derek used is an example of a filename expansion, i.e. a special form of it,
because it does not expand to just one filename but a set of filenames,
that make up the directory? (Or is it, therefore, an array?). I tend to say 
"set", because in Python3 these braces would enclose a set, but maybe this 
is misleading.

> This is because a redirection opens a file and attaches the new file
> descriptor to the process running the command. As such it inherently is an
> open of one specific file, not some kind of open of many files.

Thanks for this explanation: that is what I was asking/looking for.

> If you want to process many files a redirection is the wrong tool. You have
> two routes: pass many files on the command line as arguments to a command
> which accepts many files, or use a command like "cat" to collect all the
> data and feed it to the target command using a pipe; in a sense a pipe is a
> redirection with a command on the other side instead of a file.
> 
Yes, that's (the latter) an instructive comparison, true.

Well, let's go scripting! Thanks.

felixs

Reply via email to