Alias for Command Parameter for Bash

bash的alias(别名)不直接支持$1,$2,$3,这样的命令行参数.

所以我们可以在/etc/bashrc中, 使用函数来替代.

(但是我不知道为什么貌似alias temp='echo $1', 这样会把对temp的参数打印出来, 需要进一步确认...)

Anyway, 比如像下面这样, 可以满足我的需求

ils() {
  find . -maxdepth 1 -iname \*$1\*
}

rls() {
  ls -al *$1*
}

BASH : Alias and Parameters

http://chinmaykamat.wordpress.com/2009/09/16/bash-alias-and-parameters/

Make bash alias that takes parameter?

http://stackoverflow.com/questions/7131670/make-bash-alias-that-takes-parameter

Pass Command Line Arguments To a Bash Alias Command

http://www.cyberciti.biz/faq/linux-unix-pass-argument-to-alias-command/

Alias, Setting command aliases

http://www.linuxhowtos.org/Tips%20and%20Tricks/command_aliases.htm

猜你喜欢

转载自wjason.iteye.com/blog/1997273