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

Re: Bash globbing files only?



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?


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