Use Alias in Bash Script

A few weeks ago, I had trouble accessing aliases in bash scripts. It turns out that aliases are not expanded in scripts, only when the shell i interactive. However, we can get around this by using shopt to expand_aliases at the top o our script.

#!/bin/bash
shopt -s expand_aliases
...

Leave a Reply

Your email address will not be published. Required fields are marked *