export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/my/lib
error:
Bad : modifier in $ (/)
echo $SHELL
/bin/tcsh
I want to add my library to LD_LIBRARY_PATH variable. But Gives the above error.
As Ignacio Vazquez-Abrams, pointed out you need to set environment variable in tcsh
syntax as
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:"/home/my/lib"
# Assign empty string to LD_LIBRARY_PATH, if the variable is undefined
[ ${?LD_LIBRARY_PATH} -eq 0 ] && setenv LD_LIBRARY_PATH ""
setenv LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:/home/my/lib"
Checking if the Variable is Defined
If the variable was not previously defined, the simple setenv LD_LIBRARY_PATH value
command will fail with an error like LD_LIBRARY_PATH: Undefined variable.
. To prevent this, check the value of ${?LD_LIBRARY_PATH}
(substitutes the string 1
if name is set, 0
if it is not) and set a default value as it is shown above.
Using Double Quotes
Also note the use of double quotes. Suppose the variable contains spaces, e.g.:
setenv LD_LIBRARY_PATH "/home/user with spaces/lib"
Then the command without quotes:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/my/lib
will fail with the following error:
setenv: Too many arguments.
In double quotes, however, the value is passed to the command as a single word.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With