Windows, , . , Windows , ( -), Linux/Unix . Windows, Linux , - .
bash,
./do-for.sh repo-'*' git commit -a -m "Added new files."
./do-for.sh repo-\* git commit -a -m "Added new files."
- , , . , , , ( , do-for.sh script, , .)
, , , , , ( , , .)
, , , , , .
, , , . , (, , ).
- . , * script. ( , split, non-globbed , .) ( ). :
./do-for.sh repo- git commit -a -m "Added new files."
./do-for.sh . git commit -a -m "Added new files."
./do-for.sh repo/ git commit -a -m "Added new files."
./do-for.sh repos/. git commit -a -m "Added new files."
, , SQLs % character
./do-for.sh repo-% git commit -a -m "Added new files."
./do-for.sh user-%-repo git commit -a -m "Added new files."
./do-for.sh % git commit -a -m "Added new files."
, , bash.
:
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "Usage: ${0##*/} PREFIX command..." >&2
exit 1
fi
pathPrefix="$1"
shift
case "$pathPrefix" in
(*/) pathPrefix="${pathPrefix%/}" ;;
(*.) pathPrefix="${pathPrefix%.}*" ;;
(*) pathPrefix+=\* ;;
esac
tmp=${pathPrefix//[^\/]}
maxDepth=$((1+${#tmp}))
declare -a directories=()
while read d; do
directories+=("$d")
done < <(find . -maxdepth "$maxDepth" -path ./"$pathPrefix" -type d -print)
curDir="$(pwd)"
for d in "${directories[@]}"; do
cd "$d";
"$@"
cd "$curDir"
done
Windows, ,
./do-for.sh 'repository for project' git commit -a -m "Added new files."
( , , , , , , % -patterns .)
Windows Linux, , ..