bash中alias的命令有多层引号怎么处理

比如这个命令,我在更新所有的git branch。

git branch | awk 'BEGIN{print "echo ****Update all local branch...@daimon***"}{if($1=="*"){current=substr($0,3)};print a"git checkout "substr($0,3);print "git pull --all";}END{print "git checkout " current}' |sh

现在我要把这个命令alias到gitpullall下

alias gitpullall="git branch | awk 'BEGIN{print "echo ****Update all local branch...@daimon***"}{if($1=="*"){current=substr($0,3)};print a"git checkout "substr($0,3);print "git pull --all";}END{print "git checkout " current}' |sh"

这样是不行的。应该怎么写呢?

阅读 6.3k
1 个回答

也許可以考慮不要寫那麼複雜的 alias, 把它存成一個 bash 命令稿, 再

  • alias 指向該命令稿

  • 將該命令稿放在 PATH 底下


我回答過的問題: Python-QA

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题