Here are some more options for your toolkit. If you have only one command to execute in groups of files / directories, you findcan do this directly:
find . -type d -exec chmod 755 {} +
If a command can only work in one file / directory at a time, use \;instead +for starting one for each item:
find . -type d -exec chmod 755 {} \;
And if you need to do something complicated (i.e. a few commands), you can make a safe version of the loop:
while IFS= read -r -u3 -d $'\0' dir; do
sudo chown gkudelis "$dir"
chmod 755 "$dir"
touch "$dir/.perms_reset"
done 3< <(find /tmp -type f -print0)
, (<(...)), ; bash -only, script #!/bin/bash, #!/bin/sh. , fd 3 stdin, , - stdin, . , ("$dir" ), . . BashFAQ # 020.