Robin92
Robin92

Reputation: 561

Removing entries from LD_LIBRARY_PATH

I'm experimenting with Linux shared libraries and added an entry (export LD_LIBRARY_PATH=/path/to/library:${LD_LIBRARY_PATH}) to $LD_LIBRARY_PATH. Now I wish it gone. How can I do that?

PS. Typing echo $LD_LIBRARY_PATH before I added an entry gave me an empty line. Now it says:

path/to/library:

Upvotes: 12

Views: 53991

Answers (2)

sirgeorge
sirgeorge

Reputation: 6541

If previously it gave you empty line it (most probably) means that the variable was not set (by default it is not set), so you can just unset it:

unset LD_LIBRARY_PATH

A few other options to experiment:

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 path from the end:

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

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

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH/${MY_PATH}:/}"

Upvotes: 23

Carl Norum
Carl Norum

Reputation: 224972

Assuming you're using bash, you can set it back to an empty path using:

export LD_LIBRARY_PATH=""

And if you want to un-export it:

export -n LD_LIBRARY_PATH

The bash man page is a great piece of documentation to help out with this kind of problem.

Upvotes: 3

Related Questions