Hello everyone,
I am having problems figuring this out.
This script below is supposed to create a list of file names with their "md5sum", in a file "lib-list.txt"
When I run it "sh component-list.sh " I get this:component-list.sh: 4: component-list.sh: function: not found
component-list.sh: 5: local: not in a function
Interestingly, I have run it in debug mode and it populated the said text file with a list of lib files
Am running it on Debian 7.
Here is the script:
#!/bin/bash
cd /usr/local/activemq
function list_dir {
local path=$1
local level=$2
file=$3
#echo $path
#echo $level
if [ $level -gt 2 ];then return;fi
for i in `ls $path`
do
local line=""
for n in `seq 0 $level`
do
line+="\x20\x20"
done
if [ `echo $i | grep -E "\.zip$|\.jar$"` ]
then
md=`md5sum $path/$i | awk '{print $1}'`
echo -e $line${i##*/}"\x20\x20\x20\x20"$md >> "./$file"
fi
done
for i in `ls $path`
do
local line=""
for n in `seq 0 $level`
do
line+="\x20\x20"
done
if [ -d $path/$i ]
then
echo -e $line${i##*/} >> $file
list_dir $path/$i $[level+1] $file
fi
done
}
rm lib-list.txt
echo -e "lib" >> lib-list.txt
list_dir ./lib 0 lib-list.txt
Can someone help me out please.