#!/bin/bash function readDir(){ #echo $1 #echo $2 targetDir=`ls $1` #
是键盘上'~'下面的符号,不是单引号 for fileName in $targetDir do if [ -d $1"/"$fileName ] #
两端要有空格,不然报错 then #echo $1"/"$fileName readDir $1"/"$fileName $2 else #echo
$fileName #echo ${fileName:0-3} if [[ ${fileName:0-3} == '.py' ]]; # 查找扩展名为
.py的文件 then echo $1"/"$fileName >> $2/findPy elif [[ ${fileName:0-5} == '.html'
]]; # 查找扩展名为 .html的文件 then echo $1"/"$fileName >> $2/findHtml elif [[
${fileName:0-3} == '.js' ]]; # 查找扩展名为 .js的文件 then echo $1"/"$fileName >>
$2/findJs elif [[ ${fileName:0-2} == '.h' ]]; # 查找扩展名为 .h的文件 then echo
$1"/"$fileName >> $2/findC fi fi done } readDir $1 $2 #分别代表两个参数,即后面调用时传入的
'遍历目标文件夹路径' 和 '遍历结果保存路径'
给脚本添加执行权限:
chmod 755 findClass.sh (7:x:执行=1 + r:读=4 +w:写=2;5:x + r) 或者 chmod +x
findClass.sh
执行脚本:
./findClass.sh '遍历目标文件夹路径' '遍历结果保存路径'

技术
今日推荐
PPT
阅读数 106
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信