this post was submitted on 11 Aug 2024
29 points (96.8% liked)
Linux
14811 readers
305 users here now
A community for everything relating to the GNU/Linux operating system (except the memes!)
Also, check out:
Original icon base courtesy of lewing@isc.tamu.edu and The GIMP
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You're probably over-complicating things. Have you heard about the
find -print0 | xargs -0idiom? all that variable interpolation (dir=${dir:2}) and quoting"'""${dir}""'"is better to be dealt by the built-in shell tools. Or you could write a script for the whole body of that while loop, and then callfind . -exec ./action.sh {} \;. Same script could be used with the previously mentioned idiom too, you'd need to usebash -c ./action.shthough. One advantage of "find | xargs" is that you can run these concurrently, paralellizing the action to all your dirs, in groups, of say 4 of them... and so on... it's cool and simple.