如何遍历目录递归地找到与特定扩展名的文件 [英] How to loop through a directory recursively to find files with certain extensions
本文介绍了如何遍历目录递归地找到与特定扩展名的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要遍历目录递归并删除与.pdf扩展名and.doc的所有文件,我通过目录管理循环递归而不是设法过滤与上述文件扩展名的文件。
I need to loop through a directory recursively and remove all files with extension .pdf and.doc , I'm managing to loop through a directory recursively but not managing to filter the files with the above mentioned file extensions.
我的code到目前为止
My code so far
#/bin/sh
SEARCH_FOLDER="/tmp/*"
for f in $SEARCH_FOLDER
do
if [ -d "$f" ]
then
for ff in $f/*
do
echo "Processing $ff"
done
else
echo "Processing file $f"
fi
done
我需要帮助来完成code,因为我没有在任何地方得到。
I need help to complete the code, since I'm not getting anywhere.
推荐答案
找到
只是为取得。
find /tmp -name '*.pdf' -or -name '*.doc' | xargs rm
这篇关于如何遍历目录递归地找到与特定扩展名的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文