Files
dotfiles/local/bin/foreach
Ismo Vuorinen 2369eae0ef foreach
2022-12-15 14:38:32 +02:00

17 lines
304 B
Bash

#!/usr/bin/env bash
#
# foreach <folder> <commands that should be run to each file>
#
# Source: https://github.com/mvdan/dotfiles/blob/master/.bin/foreach
cmd=$1
shift
for dir in $($cmd); do
(
echo "$dir"
cd "$dir" || exit 1
eval "$@" # allow multiple commands like "foo && bar"
)
done