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