usage: bash script.sh <path/>
!/bin/bash
path=$1
#如果是空,必须踢出,否则会把所有音频都写进去
if [[ $path == "" ]];then
exit
fi
cd $path
#若当前路径存在存储文件,优先删除
if [[ `ls | grep "file_name.lst"` != "" ]] || [[ `ls | grep "wav.lst"` != "" ]];then
rm -rf file_name.lst wav.lst
fi
#通过find命令搜寻所有wav文件
find . -name "*.wav" >> file_name.lst
cat file_name.lst | while read line
do
name=${line:2:${#line}}
echo $name $path$name >> wav.lst
done
#处理完成后删除查询文件
rm file_name.lst
网友评论