find
command.In GNU find
, you can use -execdir
parameter:
find . -type d -execdir realpath "{}" ';'
or by using -exec
parameter:
find . -type d -exec sh -c 'cd -P "$0" && pwd -P' {} \;
or with xargs
command:
find . -type d -print0 | xargs -0 -L1 sh -c 'cd "$0" && pwd && echo Do stuff'
Or using for loop:
for d in */; { echo "$d"; }
For recursivity try extended globbing (**/
) instead (enable by: shopt -s extglob
).
For more examples, see: How to go to each directory and execute a command? at SO