linux shell编程 从当前目录下查找指定文件,输出文件位置

#! /bin/bash
#从当前目录下找出所有要查询的文件并输出文件位置

echo start time=`date`
echo -e
function func()
{
for file in `ls $2`
do 
	if [ -L $2"/""$file" ]
	then
		continue
	else
		if [ -d $2"/""$file" ]
		then
			path=$2"/""$file"
			func $1	$path	
		else 
			if [ $1 = $file ]
			then
			echo file pwd= $2"/""$file"
			fi
		fi
	fi
done
}

func $1 `pwd`
echo -e
echo end time=`date`


发布了35 篇原创文章 · 获赞 18 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/Z_Dream_ST/article/details/79105618