You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
773 B
30 lines
773 B
#! /bin/bash
|
|
find_list=()
|
|
index=0
|
|
function read_dir() {
|
|
|
|
for file in $(ls $1); do
|
|
local path=$1"/"$file
|
|
if [ -d $path ]; then #注意此处之间一定要加上空格,否则会报错
|
|
read_dir $path $2
|
|
else
|
|
#echo $path #在此处处理文件即可
|
|
extendname=${file##*.}
|
|
if [ "$extendname" == "$2" ]; then
|
|
|
|
find_list[index]="$path"
|
|
echo "找到${2}文件:${find_list[index]}"
|
|
index=$((index + 1))
|
|
# else
|
|
# echo "$file不匹配 $2"
|
|
|
|
fi
|
|
fi
|
|
done
|
|
#echo "数组元素个数为: ${#find_list[*]}"
|
|
}
|
|
#读取第一个参数
|
|
|
|
read_dir $1 $2
|
|
echo "c-数组元素个数为: ${#find_list[*]}"
|
|
return 0
|
|
|