簡體   English   中英

我可以使用參數做別名嗎?

[英]Can I make an alias with a parameter?

所以我想運行一個腳本,要求我輸入文件名。

例如: /userthatisnotme/bin/move filename

所以我想讓我更容易記住,所以我可以只輸入move filename而不是整個路徑。

我怎樣才能做到這一點?

在您的bash_profile(或其他shell配置文件腳本)中:

alias my_move="/userthatisnotme/bin/move"

此處的ls別名示例: http : //github.com/adamv/dotfiles/blob/master/bashrc#L45

“參數”放在別名之后。 對於更復雜的情況,您可以使用shell函數代替別名。

使用子例程。

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

將其保存在您的庫中,例如mylibrary 當您要使用它時,只需提供它即可。 . mylibrary . mylibrary或源mylibrary

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM