Bash globbing files only?

kodis at mail630.gsfc.nasa.gov kodis at mail630.gsfc.nasa.gov
Mon Jan 29 13:05:28 UTC 2007


On Sun, Jan 28, 2007 at 12:12:11PM -0800, Daniel Qarras wrote:
> Hi all,
> 
> with Bash one can list directories (excluding dot dirs) like this:
> 
> ls [^.]*/
> 
> How can I list files instead of directories with Bash? I thought this
> would be trivial but I can't find a solution anywhere.

I don't think that it can be done with bash, but if you don't mind
switching to zsh -- another extended version of the Bourne shell -- it
does become trivial:

    ~% ls *(.)  # list only plain files
    ~% ls *(/)  # list only directories
    ~% ls *(*)  # list only executable files

-- John Kodis.




More information about the fedora-list mailing list