BASH_ALIASES is an internal Bash associative array

suggest change

Aliases 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents