Re: Bash globbing files only?

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

 



On Sun, 2007-01-28 at 12:12 -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.

Daniel,

My knowledge of bash is very limited, but I believe that the -d
conditional checks if a file is a directory. So you could define a
function something like this (the syntax is probably all wrong, but
hopefully it is decipherable):

for file in `ls -1`; do
    if ![ -d file]; then
        printf "$file\n"
    fi
end

Name the function something like "lsfiles" and you're good to go.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux