Linux设置环境变量PATH路径的两种方法

echo 'export dataPath=$HOME/data/pre' >> ~/.bash_profile
# 路径即刻生效:
# . .bash_profile 或 source .bash_profile 或 exec bash --login

echo 'export dataPath=$HOME/data/pre' >> ~/.bashrc
. .bashrc
  • 环境变量去重
export PATH=$(printf "%s" "$PATH" | awk -v RS=':' '!a[$1]++ { if (NR > 1) printf RS; printf $1 }')
posted @ 2017-05-09 10:37  bregman  阅读(475)  评论(0)    收藏  举报