对多个git目录批量执行 git pull
使用linux shell
#!/bin/bash
dir222="$1"
echo "$dir222"
## check whether file exists
if [ -f $dir222 ]; then
echo "请传递要扫描的目录:"
exit 0
fi
## method must be added before where is invoked
gilPul()
{
echo "----------------------"
filepath2="$1"
echo $filepath2
cd "$filepath2"
git pull
}
## get all folder in "$dir222"
for i in `ls "$dir222"`;do
# echo "current path:`pwd`"
cd "$dir222"
if [ -d $i ];then
gilPul "$i"
fi
done
注意
- linux shell 函数 必须在使用前声明;
- 获取函数的第一个参数: $1
- 判断是否是目录 :test -d <路径>