简体   繁体   中英

Script that goes through files in a directory AND subdirectories

I have a simple problem to which I don't find the answer on the net.

Like the title states it, I would like to go trough all the files in a directory AND his sub-directories. I know how to do it with find command but I would like to know how to do it with a simple for loop.

I initially have this line :

for file in $dir/*.png; do

And I'm sure there is a way to have some kind of $dir/*/*.png line that makes it possible with a for loop.

Thanks for your answers.

for file in $(find $dir - type f - name "*.png"); do

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM