2010-10-23 57 views
0

所以我想运行一个脚本,需要我输入文件的名称。我可以使用参数制作别名吗?

例如: /userthatisnotme/bin/move filename

所以我想使我更容易记住,这样我就可以键入move filename的而不是整个路径。

我该怎么做?

回答

3

在你的.bash_profile(或其他shell脚本配置文件):这里LS别名

alias my_move="/userthatisnotme/bin/move" 

例子:http://github.com/adamv/dotfiles/blob/master/bashrc#L45

“参数” 的放入别名之后。对于更复杂的情况,您可以使用shell函数而不是别名。

1

使用子程序。

mymove(){ 
/userthatisnotme/bin/move "$1" 
} 

将其保存到你的数据库,如mylibrary。当你想使用它,只需要它来源。 . mylibrary或来源mylibrary