bashrc别名的动态目录名称

时间:2019-05-17 13:12:22

标签: linux bash command

我已经在gotochild2文件中创建了别名.bashrc,以更改特定路径/parent/child1/child2。现在,我希望用户在child2中输入动态目录。 例如,gotodir files必须去/parent/child1/child2/files。如何在.bashrc中指定?

1 个答案:

答案 0 :(得分:2)

如果要传递类似gotodir files的参数,请使用函数代替别名。
参见Make a Bash alias that takes a parameter?

gotodir () {
    cd "/parent/child1/child2/$1"
}