Skip to content

Instantly share code, notes, and snippets.

@treywelsh
Last active April 23, 2018 20:50
Show Gist options
  • Save treywelsh/85a78368abd737bf0ab5f8fdecfc946e to your computer and use it in GitHub Desktop.
Save treywelsh/85a78368abd737bf0ab5f8fdecfc946e to your computer and use it in GitHub Desktop.
subex ./ git log --oneline
NOTES:
git repository not tested
work only at first directory level
Could be useful with git aliases to run on a list of repos
#!/usr/bin/env bash
if [ $# -lt 2 ]; then
echo "USAGE: $0 directory command"
exit 1
fi
DIR="$1"; shift
CMD="$@"
export CMD
find $DIR -mindepth 1 -maxdepth 1 -type d \
| xargs -I {} -n 1 sh -c "echo {} \
&& cd {} \
&& $CMD \
&& echo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment