Instead of doing something like find . -type d -execdir ... \;
you can run redo
with the command you want to have executed recursively in the subdirectories of the working directory.
If Homebrew is installed, you can run this command:
brew install vbwx/utils/redo
- Download and extract the latest release of redo.
- If desired, move the completion script(s) to the appropriate location on your system.
- Move
completion/redo
to a directory like/etc/bash_completion.d
. - Move
completion/_redo
to a directory like/usr/share/zsh/site-functions
.
- Move
- Move
redo
to a directory such as/usr/bin
.
Run redo --help
to get a quick overview of how to use this utility.
redo [--quiet] [--strict] [--follow] [--hidden] [--nocd]
[--mindepth N] [--maxdepth N] [--depth N]
[--] [+INCLUDE_GLOB ...] [-EXCLUDE_GLOB ...]
[+] [DIR ...] [-] [SCRIPT_OR_EXECUTABLE [ARG ...]]
You can use the following variables in the script supplied to redo
.
DIR
CWD
(unless--nocd
is specified)COUNT
INDEX
DEPTH
RUNS
FILES
SUBDIRS
LEAF
ROOT
RCOUNT
RINDEX
redo echo \$CWD
redo --nocd echo \$DIR # same result
redo echo \$PWD # absolute paths
redo --hidden -.git echo \$INDEX
redo <<< 'echo "($DEPTH) $INDEX/$COUNT: $CWD"'
redo echo '"$CWD ($SUBDIRS directories, $FILES files)"'
redo --mindepth 2 --maxdepth 3 echo \$CWD
redo --quiet SetFile -a E '*.*' # executed in subdirectories recursively
redo --quiet . SetFile -a E '*.*' # also executed in working directory