2007-05-17, 18:14(-07),
paintedjazz@gmail.com:
> Is there a way in a bash script to detect if the directory one is
> about to cd into is a directory that begins with a dot?
>
> e.g.
>
> find . -type d |
> while read dir
> do
> if [ $dir begins with a dot ]
> then
> continue
> else
> do stuff
> fi
> done
[...]
case ${dir##*/} in
(.*) ...
esac
Note that find's output is not post-processable unless you use
some trick or can guarantee that none of the file names contain
newline characters. find has a -exec predicate, there should be
no need to use a while loop.
read alone is for something very special. If you want to read a
line of input, it's IFS= read -r dir.
Note that there's no guarantee that the while loop will or will
not be run in a subshell in the code above. So if for instance
you do a cd in that loop, it may only change the current
directory of that subshell.
--
Stéphane