导读:遍历整个文件夹及子目录。将所有mpg格式的文件及其路径保存到记事本a.txt中。#!/bin/bashfunction ergodic(){for file in ` ls $1`do...
遍历整个文件夹及子目录。将所有mpg格式的文件及其路径保存到记事本a.txt中。
#!/bin/bash
function ergodic(){
for file in ` ls $1`
do
if [ -d $1"/"$file ]
then
ergodic $1"/"$file
else
local path=$1"/"$file #得到文件的完整的目录
local name=$file #得到文件的名字
#做自己的工作.
if [ "${file##*.}" = "mpg" ]; then
echo $1"/"$file >>a.txt
fi
fi
done
}
INIT_PATH="."
ergodic $INIT_PATH