[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Bash globbing files only?

Daniel Qarras wrote:
> I want just the files from the current directory, not from any subdir.
> And I'd prefer some bash globbing if possible for performance/elegancy
> reasons :)

Les Mikesell wrote:
> The only way to do it without an external command would be to expand
> the list in the shell and cycle though the list eliminating the
> directories with a [ -d $VAR ] test. See 'man test' for the options,
> but it really is a shell built-in.

That won't work reliably, either -- directories can contain more things
than plain files or subdirectories. There could be symbolic links,
character or block device nodes, named pipes or sockets.

Daniel should probably briefly consider what he wants to do with any of
these, and program around them. (I suspect "following symbolic links and
ignoring the rest" may be a good heuristic".)

Hope this helps,


E-mail:     james@ | A wood-pigeon would, If a wood-pigeon could,
aprilcottage.co.uk | But a wood-pigeon can't, So it won't.
                   | A wood-pigeon could, If a wood-pigeon would,
                   | But a wood-pigeon doesn't want to. So it doesn't.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]