Linux
如何從 PATH 變數中替換某個路徑?
我正在使用 Cygwin,並想通過 bash shell 修改以下 PATH:
/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VSTSDB/Deploy:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/HTML Help Workshop:/cygdrive/c/Program Files (x86)/HTML Help Workshop:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/bin/NETFX 4.0 Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/bin:/cygdrive/c/Python33:/cygdrive/c/_WORK/java/jdk1.6.0_30/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/DLLShared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/10.0/DLLShared:/cygdrive/c/Program Files/WIDCOMM/Bluetooth Software:/cygdrive/c/Program Files/WIDCOMM/Bluetooth Software/syswow64:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/cygdrive/c/Program Files (x86)/apache-ant-1.8.3/bin:/cygdrive/c/Program Files (x86)/Code Collaborator Client:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon
路徑很大。
中間某處有
c/_WORK/java/jdk1.6.0_30/bin
。我想做的是暫時將其替換為
c/_WORK/java/jdk1.7.0_40/bin
換句話說,我想使用不同的 Java SDK 版本。有時我會使用 1.6 有時會使用 1.7。
我將如何更改 Java SDK 路徑?
簡單地說,通過執行以下命令來自定義變數:
PATH="path_to_your_jdk_bin_dir:$PATH" export PATH
新路徑將優先於另一條路徑。要使此更改在您的配置文件中永久生效,請將這兩行放入
~/.bash_profile
or~/.profile
文件中。此外,我建議
JAVA_HOME
正確設置變數。
您可以創建符號連結