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