BASH_ALIASES is an internal Bash associative array
suggest changeAliases are named shortcuts for commands that one can define and use in interactive bash instances. They are held in an associative array named BASH_ALIASES. To use this variable in a script, the script must be run within an interactive 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents