I'm using in xubuntu bionic as shell bash.
I'll try to expand my $PATH for my user over $HOME/.profile.
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
The result is a little bit unexpected.
echo $PATH
/home/alex/.local/bin:/home/alex/bin:/home/alex/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$HOME/bin is set twice. How can I avoid it?
In $HOME/.bashrc is nothing declared.
Ubuntu is already configured to automatically add
$HOME/bin
to the path.You mentioned you're distribution was Server converted to Desktop and I'm not sure how that effects things but you can check:
It sounds like this is being executed and what you are manually doing is doubling up on the last line in the file.
Using
grep
to find all referencesYou can use grep to find all the files where
$HOME/bin
is referenced:I use Stephen Collyer's "Bash Path Functions" (see his article Stephen Collyer's article in Linux Journal). It permits me to use the "colon separated list" as a datatype in shell programming. For example, I can produce a list of all the directories in the current directory by:
Then, listpath -p dirs produces a list.
Using
uniqpath
andlistpath
(from bash_path_funcs), one could simply: