Bash – How to test if a particular alias is defined

aliasbash

I have a bash script that needs to behave differently if a particular alias is defined. Is there a way to test if a particular command is an alias in bash?

Best Answer

if alias <your_alias_name> 2>/dev/null; then 
  do_something
else 
  do_another_thing; 
fi
Related Question