bash 脚本如何重写内部命令

# 举例子,修改cd的默认路径
function cd()
{
  if [ $# == 0 ]; then
    builtin cd ~/work
  else
    builtin cd $*
  fi
}

ref如下,一下博客中 还有其他方法,只是选了其中一个,try and it works

https://www.tutorialkart.com/bash-shell-scripting/bash-override-commands/#:~:text=Bash – Override Commands %3A In this Bash,have to create a function with name ps.

posted @ 2023-03-09 09:07  wangshaodong  阅读(16)  评论(0编辑  收藏  举报