/redo

Small script that executes any program recursively in a directory tree.

Primary LanguageShellMIT LicenseMIT

Shell MIT license

redo

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.

Installation

Installation via Homebrew

If Homebrew is installed, you can run this command:

brew install vbwx/utils/redo

Manual Installation

  1. Download and extract the latest release of redo.
  2. 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.
  3. Move redo to a directory such as /usr/bin.

Usage

Run redo --help to get a quick overview of how to use this utility.

Synopsis

redo [--quiet] [--strict] [--follow] [--hidden] [--nocd]
     [--mindepth N] [--maxdepth N] [--depth N]
     [--] [+INCLUDE_GLOB ...] [-EXCLUDE_GLOB ...]
     [+] [DIR ...] [-] [SCRIPT_OR_EXECUTABLE [ARG ...]]

Environment Variables

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

Examples

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