警告:這個問題不是關於git的使用,而是關於在Linux中使用管道的問題,這裏給出git
命令作爲示例。在另一個命令的輸出中給出的執行行
具有git push
fatal: The current branch my_branch has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin my_branch
我想執行給定的命令這樣的輸出,即git push --set-upstream origin my_branch
。
通過做git push 2>&1 | tail -3
我得到git push --set-upstream origin my_branch
印在屏幕上。
問題:什麼命令應該被添加到下一個管道,因此給定git push
將被執行。所以,我可以做git push 2>&1 | tail -3 | command_to_eval_given_string
你想'尾巴-1',而不是'尾巴-3' ......這只是最後一行。 – gilez