1

I am having a little problem with my ubuntu16.04 terminal. I wanted to have access to a data-base through the use of the :

echo source /Infos/bd/config11 >> .bashrc

echo source /Infos/bd/config11 >> .bash_profile

However I unfortunately don't have acces to this data-base since it's not on my computer. Every time I open a terminal I see:

bash: /Infos/bd/config11: No such file or directory

What can I do to stop seeing this on my terminal?

Thank you.

2 Answers2

3

If your startup scripts are shared and you'd like the source command to execute if possible, then wrap it in a test:

[ -r /Infos/bd/config11 ] && source /Infos/bd/config11

On systems without that file (specifically, where your account is unable to read that path), the test will fail and you will not receive an error message; on systems with that file (where you can read that file), it will be sourced in.

You may not need to have the command in both files; see, for example What is the purpose of .bashrc and how does it work?, and/or your local bash man pages.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
2

To avoid seeing this, you should edit your startup scripts so they no longer attempt to source the missing file:

sed -i 'sXsource /Infos/bd/config11X#&X' ~/.bashrc ~/.bash_profile

This will comment out the line in both files.

Stephen Kitt
  • 434,908