获取路径下文件路径和文件名

usage: bash script.sh

!/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

你可能感兴趣的:(获取路径下文件路径和文件名)