0

When I write in .bashrc:

export PATH=\$PATH:\/usr/local/qc/OPENMPI_3_1_4/bin/

after a reboot, I get this error with any command line:

david@doc1:~> less
If 'less' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf less

It only work with the complete path:

/usr/bin/less

How can I solve this problem?

1 Answers1

4

You do not need to escape the dollar character

export PATH=\$PATH:\/usr/local/qc/OPENMPI_3_1_4/bin/

This means you are creating a new PATH with a text $PATH:/usr/local/qc/OPENMPI_3_1_4/bin/. The existing PATH is lost at that moment. What you need is

export PATH=$PATH:/usr/local/qc/OPENMPI_3_1_4/bin/

In this case, the old value of PATH (something like /bin:/usr/bin) is replacing the $PATH and result would be /bin:/usr/bin:/usr/local/qc/OPENMPI_3_1_4/bin/

You will (or can) write PATH=abc\$def if the dollar sign is part of the directory name. Which is extremely rare and almost never happen, since the $ character is used to mark substitutions, and you would have to escape it to reference such directory.

John1024
  • 74,655
White Owl
  • 5,129
  • Safer to quote the whole part after the =, in case some of the additions contain whitespace, or are subsequently edited to do so. – Paul_Pedant Jul 01 '20 at 07:42