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

Re: Bash globbing files only?



Hi!

--- Cameron Simpson <cs zip com au> wrote:

> A POSIX shell requires that the test command supports this:
> 
>        -h  file
>               True if file exists and is a symbolic link.
>        -L  file
>               True if file exists and is a symbolic link.

Thanks, I already saw those but initially they did not work for
directories. That was because I had

dirs=[^.]*/

that would expand, e.g:

foo/
bar/

and the trailing slash caused -L test to fail. So, finally, I have what
I wanted without any external commands like this:

dirs=[^.]*/
for d in ${dirs}
do
  if [[ -d ${d//\//} && ! -L ${d//\//} ]]
  then
    echo processing dir $d
  fi
done
# ...
files=[^.]*
for f in ${files}
do
  if [[ -f ${f//\//} && ! -L ${f//\//} ]]
  then
    echo processing files $f
  fi
done

Thanks!




 
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html 


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