开发者

Parse another script's output

I'd like to do a script which, among other stuff, grabs the output of git branch and gets the selected branch. The typical output would be:

master
develop
* release-1.0
...

And I would want to get:

release-1.0

I guess it could be done using开发者_StackOverflow中文版 pipes, but I have not a single clue. Could you mates help me with this? Thanks in advance!


Use the plumbing instead:

branch=$(git symbolic-ref HEAD)

git branch's output is considered porcelain and is not recommended for use in scripts.


line=$(git branch|grep '*')
echo ${line#* }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜