BASH ALIASES 是一个内部 bash assoc 数组

别名是命令的快捷方式,可以在交互式 bash 实例中定义和使用。它们保存在名为 BASH_ALIASES 的关联数组中。要在脚本中使用此变量,必须在交互式 shell 中运行它

#!/bin/bash -li
# note the -li above! -l makes this behave like a login shell
# -i makes it behave like an interactive shell
#
# shopt -s expand_aliases will not work in most cases

echo There are ${#BASH_ALIASES[*]} aliases defined.

for ali in "${!BASH_ALIASES[@]}"; do
   printf "alias: %-10s triggers: %s\n" "$ali" "${BASH_ALIASES[$ali]}" 
done