I'm trying to create a bash script which has a list of aliases and run them in my script. (This is just a simplified example, but it explains the situation).
What should happen is I loop over my aliases and the script executes them one by one.
alias_list.sh
#!/bin/bash
alias al1="ls"
alias al2="ls ."
alias al3="ls .."
test_alias_loop.sh
#!/bin/bash -i
# Expand aliases
shopt -s expand_aliases
source ~/Documents/test_ssh_bash/scripts/alias_list.sh
# Exists just to get a list of aliases, proper version gets aliases from bash command
aliases=$(printf "al1\nal2\nal3\n\n")
for ssh_alias in $aliases; do
echo "$ssh_alias"
$ssh_alias
done
This is what I get for the first command ./test_alias_loop.sh: line 12: al1: command not found
But, when I just do
al1
The command runs and I get an ls of my current directory.
How can I loop over a list of alias commands and actually run them in my script?