I encountered a problem when I was trying to source a .bashrc.user file. It worked fine when I source the file in the terminal, it gave no complaints. But when I tried to do the same in my bash script, it gave some issues. here is how my code looks like:
comm -13 <(sort -u ~/.bashrc.user) <(sort -u ~/my_script/bashrc.user) > bashrc_diff
if [ -s bashrc_diff ]; then
cat bashrc_diff >> ~/.bashrc.user
source ~/.bashrc.user
printf ".bashrc.user has been configured successfully!\n"
else
printf ".bashrc.user is up-to-date!\n"
fi
rm bashrc_diff
source ~/.bashrc.user
So whenever I execute this code in my script, it gives and error and says that module: command not found
. In the .bashrc.user file there are some module commands doing things like module add git/2.22.0
etc. As I mentioned before it works fine when I source it from terminal but complains in the script with the same type of command, what could be the issue here?