Bash Alias – Creating Alias with Executable’s Name

aliasbash

I tried to implement the following line in my .bashrc,

alias ./my_exec='printf "foo"'

However, the alias doesn't work, and the following line appears :

bash: alias: `./my_exec': invalid alias name

I know that the zsh terminal can make this work, but I wouldn't switch to it for this only thing.

Is there is a way I can make this alias work ?

Best Answer

maybe you need a function

my_exec(){
   print "foo"
}

this found for me,

countryip(){

  COUNTY="$(whois $1 | grep ountry))"
  echo "$COUNTRY $1 \n"

}

$ countryip 192.168.0.1
Related Question