Deleting Records from LD_LIBRARY_PATH

I am experimenting with shared Linux libraries and added an entry ( export LD_LIBRARY_PATH=/path/to/library:${LD_LIBRARY_PATH} ) to $ LD_LIBRARY_PATH . Now I want it to disappear. How can i do this?

PS. Entering echo $LD_LIBRARY_PATH , before I added the entry, gave me an empty string. Now he says:

path / to / library:

+6
source share
2 answers

If he previously gave you an empty string, this (most likely) means that the variable has not been set (by default it is not set), so you can just turn it off:

 unset LD_LIBRARY_PATH 

Several other experiment options:

 export MY_PATH=/my/path export MY_PATH2=/my/path2 export LD_LIBRARY_PATH="${MY_PATH}:${MY_PATH2}" echo $LD_LIBRARY_PATH /my/path:/my/path2 

Removing a path from the end:

 export LD_LIBRARY_PATH="${LD_LIBRARY_PATH/:${MY_PATH2}/}" echo $LD_LIBRARY_PATH /my/path 

Similarly, removing the path from the beginning (if set above):

 export LD_LIBRARY_PATH="${LD_LIBRARY_PATH/${MY_PATH}:/}" 
+7
source

Assuming you are using bash , you can set it back to the empty path using:

 export LD_LIBRARY_PATH="" 

And if you want to export it:

 export -n LD_LIBRARY_PATH 

The bash man page is great documentation to help deal with this issue.

+2
source

Source: https://habr.com/ru/post/911010/


All Articles