how to remove a path from LD_LIBRARY_PATH in tcsh?
linux, path, shared-libraries
Solution
I'm a bash user, but I'm pretty sure this will do the job for you. It will most often leave a `::` in `$LD_LIBRARY_PATH`, but that shouldn't cause any problems.
setenv LD_LIBRARY_PATH `echo $LD_LIBRARY_PATH | perl -pe "s[$DIR_TO_REMOVE][]g;"`
For bash users who might come upon this, use the following command:
LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | perl -pe "s[$DIR_TO_REMOVE][]g;")
export LD_LIBRARY_PATH
Problem
on exiting/unloading a package, I must reset the `LD_LIBRARY_PATH` back to its previous setting by removing a certain path from it. How to do that in tcsh or csh? edit1 to clarify. Say the `LD_LIBRARY_PATH` is something like `path1:mypath:path2:path3:path4` and I do not know (in my script) anything about it except that it must contain `mypath`, [begin edit2 which is stored in the variable `$MY_PATH` end edit2] somewhere. Then I want to remove `mypath`, such that after the operation the `LD_LIBRARY_PATH` is `path1:path2:path3:path4`.