I am using Ubuntu 16.04 LTS. I am really new to Linux.
I created a softwares
directory within the Downloads
dir for all the software and added it to my PATH. Then I was advised that it's better to create a bin
directory in your home, instead of keeping directories such as Downloads in the PATH. So, I did it. Now, my problem, I have both the directories in the PATH and some of my tools are not running due to this reason.
I did try some of the suggestions given in the posts here but it didn't work for me and since I am new, I am bit scared to experiment that I'll mess up every thing.
My PATH
$ echo $PATH
/home/gjjha/bin:/home/gjjha/bin:/home/gjjha/bin:/home/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin:/home/gjjha/bin:/home/gjjha/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin://home/gjjha/Downloads/softwares/ncbi-blast-2.5.0+:/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin:/home/gjjha/home/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin:/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin:/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin:/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin:/gjjha/Downloads/softwares/bowtie2-2.2.9/index:/home/gjjha/Downloads/softwares/tophat-2.1.1:/gjjha/Downloads/softwares/bowtie2-2.2.9/index:/home/gjjha/gjjha/Downloads/softwares/bowtie2-2.2.9/index:/home/gjjha/Downloads/softwares/tophat-2.1.1:/home/gjjha/bin:/home/gjjha/bin/blastdb:/home/gjjha/bin/blast+2.5:/home/gjjha/blast+2.5/bin:/home/gjjha/blast+2.5/bin:/home/gjjha/bin/ncbi-blast-2.5.0+/bin
I want to remove the softwares dir and duplicates and want to keep /home/gjjha/bin
since all softwares are in bin dir now.
Commands I tried:
PATH=echo $PATH | sed -e 's/:\/home\/wrong\/dir\/$//'
PATH= echo $PATH | sed -e 's/:/home/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin/$//'
PATH=${PATH/%:/home/wrong/dir//}
PATH=${PATH%:/home/gjjha/Downloads/softwares//}
PATH=${PATH%:/home/gjjha/Downloads/softwares/ncbi-blast-2.5.0+/bin/}
I checked (even after rebooting), the softwares dir is still there.
sed
or parameter substitution is not the right way to approach this. Revert the changes you made then logout and login..bashrc
to set the PATH. Then it will be overidden by/etc/environment
when you log out and back in. Then you can put the path you want in.profile
(more appropriate than.bashrc
)