Bash globbing files only?

James Wilkinson fedora at aprilcottage.co.uk
Mon Jan 29 08:15:14 UTC 2007


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,

James.

-- 
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.




More information about the fedora-list mailing list