addpath/addmanpath
Assignments like
PATH=/usr/bin:/usr/local/bin:/usr/ucb/bin
are not very easy to maintain. Using a function at this point will make life much easier.
First we need a function for addpath:
# construct PATH
unset PATH # if PATH is set, unset it
addpath() {
if [ -d "$1" ]; then
if [ X"$PATH" = "X" ]; then
PATH=$1
else
if echo "$PATH" | grep -v "$1" >/dev/null 2>&1
then
PATH=$PATH:$1
fi
fi
fi
}Done! Now lets add the PATH we need:
PATH=
addpath /bin
addpath /sbin
addpath /usr/bin
addpath /usr/sbin
addpath $HOME/bin # bin in HOMEDIRAt last we have to export the variable:
export PATH
Thats it! Now we have a nice looking PATH. Put this in your .profile or .bashrc and you are ready to go.
If you need a new PATH set just call the funktion (addpath) with the wanted path as attribute.
And for the clever one, change all the stuff for addmanpath
