我想在执行时捕获输出:
git push --set-upstream ...
1个输出是:
remote: https://...
如何从该输出中进行grep(或其他操作)?
答案 0 :(得分:1)
git push | grep remote
竖线字符将git的标准输出重定向到grep的标准输入。
此外,您可以将整个输出重定向到文件:
git push > out.txt
重定向文档:https://www.tldp.org/LDP/abs/html/io-redirection.html 管道文档:http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-4.html