Bash 深度搜索

Bash Search Deep

目前我正在使用以下命令查找目录中的所有文件以查找所有 JPG 文件,但是,我还想查找扩展名 .JPG 和 .GIF。我有一些文件嵌套在几个子子文件夹下......这个命令如何为我提取所有内容?非常感谢我能得到的任何帮助!

FILES=/home/pictures/s/downloaded/*.jpg
for randomvid in $FILES
do

done
find path -type f -name '*.jpg' -o -name '*.gif' -print

在path子目录下递归搜索jpg,gif文件returns

您可以使用循环来处理它们。 正如 Etan 指出的那样,while 循环比 for.

更适合处理文件
find path -type f -type f \( -name "*.jpg" -or -name "*.gif" \) -print |
while read FILE
do  
  # Process the $FILE
done

这是一个没有管道的 grep 示例...

grep -rl --include=*.{jpg,gif} "*" ~/pictures/s/downloaded