Re: Bash globbing files only?

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

 



Hi!

--- Cameron Simpson <cs@xxxxxxxxxx> 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 


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

  Powered by Linux