For some reason, I had to add an alias to my bash. I have added the alias in /root/.bashrc
which also contains the following piece of code:
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
The new alias works like a charm when it is used in the console. However, when I execute a script file myscript.sh
with this alias in, I get a command not found
error. It seems like I should tell .sh
files to use the same environment as bash
but I don't know how to do that.
root
. Androot
really has no business using aliases in scripts. You haven't given enough information to be sure, but it sounds like you are setting yourself up for a fall. I would strongly urge you not to use aliases in shell scripts that are run by root. – terdon Dec 16 '17 at 13:19