• adr1an@programming.devOPM
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    You’re probably over-complicating things. Have you heard about the find -print0 | xargs -0 idiom? 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 call find . -exec ./action.sh {} \;. Same script could be used with the previously mentioned idiom too, you’d need to use bash -c ./action.sh though. 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.