“cd 目录;ls”的 bash 别名

fun*_*hun 3 bash alias

如何为以下对象创建 BASH 别名:

我输入cdd directory和做什么cd directory,然后ls

Raf*_*ler 8

制作一个函数会更容易:

cdd () 
{
    cd $1
    ls
}
Run Code Online (Sandbox Code Playgroud)

当然,您可以随意命名该函数。将它放在您的 .bashrc 或 .profile 或您系统上的任何文件中。

  • @funk-shun 它使 `cdd` 成为一个函数,实际上它的作用几乎与别名完全一样。但是,函数更强大并且可以接受参数。 (3认同)