Subversion Repositories svn.Prod repos

Compare Revisions

No changes between revisions

Ignore whitespace Rev 2 → Rev 3

/filefind/bash/filefind.bash
0,0 → 1,74
#!/usr/bin/env bash
# progname : filefind.bash
# purpose : display a directory tree
# similar to find
 
# =============================================================================
# Functions
# =============================================================================
 
Usage()
{
mesg="$1"
 
echo "Usage : $progname directory"
echo $mesg
}
 
#
# we need local vars to keep the value when called recursively
#
traverse()
{
local directory="$1"
 
local curdir curdir2
 
curdir=$(pwd)
cd -- "$directory"
curdir2=$(pwd)
files=$(ls)
for file in $files
do
pfile=$curdir2/$file # file including path
if [ -d "$file" -a ! -L "$file" ]
then
echo $pfile
traverse "$file"
else
if [ -f $file -o -L $file ]
then
echo "$pfile"
else
echo "WARNING: Could not process file $pfile"
fi
fi
done
cd -- "$curdir"
}
 
start_traverse()
{
directory=$1
 
echo $directory
traverse $directory
}
 
# =============================================================================
# MAIN
# =============================================================================
 
progname=$(basename $0)
if [ $# -eq 1 ]
then
directory=$1
if [ -d $directory ]
then
start_traverse $directory
else
Usage "ERROR: No directory $directory found"
fi
else
Usage "ERRROR: 1 argument expected"
fi
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/filefind/bash/Makefile
0,0 → 1,16
 
DIR = /home/arikkert
SRC = filefind.bash
 
test: $(SRC)
./$(SRC) $(DIR) > result
sort result > result.sort
find $(DIR) > result2
sort result2 > result2.sort
wc *.sort
diff *.sort
 
clean:
rm -f filefind
rm -rf result result.sort
rm -rf result2 result2.sort