我创建了一个 bash 脚本来添加
/My_Scripts/Bash_Scripts
到 linux 的默认 PATH 中。
!/bin/bash
#This Script is used to add a folder/diectory to the PATH..
echo -e "\e[92m\e[1mCREATING PATH...........\n\n"
cd
mkdir My_Scripts
cd My_Scripts
mkdir Bash_Scripts
cd
export PATH=$PATH:$HOME/My_Scripts/Bash_Scripts
echo -e "\e[92m\e[1mPATH CREATON SUCCESSFUL\n \e[39m"
echo $PATH
脚本的输出是
root@kali:~/Desktop# bash add_path
CREATING PATH...........
PATH CREATON SUCCESSFUL
`/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/My_Scripts/Bash_Scripts'
但是如果我echo $PATH
在外面的终端中输入,则不会添加路径
root@kali:~/Desktop# $PATH
bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: No such file or directory