Score:1

What does ":" do when used in export env variable?

gb flag

I am just trying to following this post.

I have replaced "/some/directory/" by "/usr/lib/x86_64_linux-gnu/", resulting in

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64_linux-gnu/

Now when I type

printenv LD_LIBRARY_PATH

it prints

:/usr/lib/x86_64-linux-gnu/

I wonder if the : is correct, and if not what I have to do differently.

I am confused why the author used

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/some/directory/

What does the "$" and the ":" do?

guiverc avatar
cn flag
the export includes the current value ($LD_LIBRARY_PATH where the '$' highlights it's talking about a variable) and new directory which is added as another place to search; the `:` acts as a delimiter between directories to search.
Score:0
za flag

The LD_LIBRARY_PATH is a collection of paths, each ending in a directory (hence you don't include specific libraries like libcudnn_cnn_infer.so.8 in it) where libraries are searched for, like the normal PATH which lists places, where to look for executable programs.

The colon (:) is the delimiter between the paths, if there is more than one.

The

export xy_PATH=$xy_PATH:/abc 

pattern is a common pattern, when a system wide setting is declared in a system wide config file in /etc for example, but later expanded by a user specific config file in his /$HOME/.xyconf. The user takes, what is already defined, and extends it.

The colon is an automatic delimiter for the shell, since it can't be part of a variable name. This makes it easy to extend it. Otherwise, you would have to write export xy_PATH=${xy_PATH}:/abc. Also note, that an empty part in front of the colon is harmless which makes the composition robust.

tmighty avatar
gb flag
Thank you. Your answer has just been added to the knowledge of an AI chat bot. :-D
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.