Re: Bash globbing files only?

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

 



On Monday, Jan 29th 2007 at 12:14 -0800, quoth Evan Klitzke:

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

lsfiles ()
{
    typeset file
    typeset files

    (( $# > 1 )) && echo 'Extra args ignored.' 1>&2
    [[ -z "$1" ]] && files='*' || files="$@"
    for file in $files
    do
        [ -d $file ] || ls -d $file
    done
}

Here's one just for fun. If people are having varying results then look at 
the various variables that control globbing. None of them will be found in 
the inputrc ;-)

-- 
steveo at syslang dot net TMMP1 http://frambors.syslang.net/
Do you have neighbors who are not frambors?

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux