【发布时间】:2016-10-03 02:36:55
【问题描述】:
尝试从http://git-scm.com 拉取最新版本的 Git,但下面的脚本似乎没有打印出任何内容...
我在这里错过了什么?
if [ -z "$CURRENT_GIT_VERSION" ]; then
if [ "`uname`" == "Darwin" ]; then
sed_regexp="-E";
else
sed_regexp="-r";
fi
CURRENT_GIT_VERSION=$(curl http://git-scm.com/ 2>&1 | grep '<span class="version">' -A 1 | tail -n 1 | sed $sed_regexp 's/ *//')
fi
echo "$CURRENT_GIT_VERSION"
不工作:
CURRENT_GIT_VERSION=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p')
echo "$CURRENT_GIT_VERSION"
也不行:
CURRENT_GIT_VERSION=$(echo $(curl -s http://git-scm.com/ | grep 'class="version"' -A 2) | perl -pe 's/.*?([0-9\.]+).*/$1/')
echo "$CURRENT_GIT_VERSION"
【问题讨论】:
标签: git bash shell installation