Niclas,
I do not understand how your script works, but if you want to use
'find' to get the path names you can do it this way
find . -name \*\.java -exec dirname {} \;
or
find . -name \*\.java -printf "%h\n"
The output of this can be piped onto :
sed 's/\//\./g'
...and that will substitute '.' characters for the '/' characters.
HTH,
Kenneth
On Sat, 29 Jan 2000, Niclas Hedhman wrote:
>
> This script goes through a directory structure and builds up Java
> package names out it, so that a directory
> abc/def/ghi will become abc.def.ghi, IF there is a Java file in it
> (*.java is given as input).
>
> Now, this is rather slow, and running
> find . -name *.java
> is a lot faster. But I need to convert the output, so that
> a) the filename is dropped.
> b) the slashes are exchanged for dots
>
> How can this be achieved?
>
> Niclas
>
> #!/bin/bash
> #
> FILTEREXPR="$1"
>
> ISPACKAGE=''
> for FILE in $FILTEREXPR; do
> if [ -f $FILE ] ; then
> ISPACKAGE=YES
> fi
> done
> if [ $ISPACKAGE ] ; then
> echo $PACKAGE
> fi
>
> for DIR in $(ls) ; do
> if [ -d $DIR ] ; then
> OLDPACK=$PACKAGE
> if [ -z $PACKAGE ] ; then
> PACKAGE=$DIR ; export PACKAGE
> else
> PACKAGE=$PACKAGE.$DIR ; export PACKAGE
> fi
> cd $DIR
> /bali/dev/builders/packager "$FILTEREXPR"
> PACKAGE=$OLDPACK
> cd ..
> fi
> done
>
>