简体   繁体   中英

Can I make an alias with a parameter?

So i want to run a script that requires me to input the name of a file.

For example: /userthatisnotme/bin/move filename

So I want to make it easier for me to remember, so I can just type move filename instead of that whole path.

How can I do this?

In your bash_profile (or other shell profile script):

alias my_move="/userthatisnotme/bin/move"

Examples of aliases for ls here: http://github.com/adamv/dotfiles/blob/master/bashrc#L45

The "parameters" get placed after the alias name. For more complicated situations, you could make a shell function instead of an alias.

use a sub routine.

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

save this in your library eg mylibrary . when you want to use it, just source it. . mylibrary . mylibrary or source mylibrary

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM