#!/bin/bash
function find (){
for file in `ls $1`
do
if [ -d $1"/"$file ] ; then
find $1"/"$file
else
local path=$1"/"
local name=$1"/"$file
#介个是获取当前的用户目录
#例如 /home/zhangsan
local home_path=/home/$USER/
#介个是 去除home的路径
#例如在 zhangsan下面有个test目录
#那么path2 的输出就会是 test/ 而不是 /home/zhangsan/test/
local rela_path=${path#$home_path}
# echo $rela_path
# echo $path
echo $name
echo 123
echo "file: $file url: $path">>./a.txt
# echo "$file">>./a.txt
fi
done
}
IFS=$'\n' # 这个必须要,否则会在文件名中有空格时出错
#INIT_PATH 是要设置的查询的路径
#本DEMO查询的是当前目录
INIT_PATH="/usr/local/tomcat/WebReport/WEB-INF/reportlets";
find $INIT_PATH