yves Baumes yves Baumes - 4 months ago 14
Linux Question

": Command not found"

Some issue arise when sourcing one of your env file (a series of variable exporting)

for instance:

...
export MY_ROOT=/Soft/dev/blah/blah
export MY_BIN=${MY_ROOT}/bin
...


results in

$. my_env.sh
$echo $MY_BIN
/bint/dev/blah/blah


=> "/bin" seems to overwrite the begining of the variable instead of suffixing it..

Any idea?

By the way every time we source this file, an error message is reported:

": Command not found"


Which is weird.. This message appears even though we comment its whole content.

The invoked shell at the begining seems good
#!/bin/sh
, or
#!/bin/bash
.

What about control characters? How to screen them on linux?

Answer

This will fix the line endings in the file:

dos2unix my_env.sh

There's no need for a shebang in a file that's only going to be sourced since it is run in the current shell anyway. However, as a comment it might be informative for human readers.