0

I would like to install something from github in a bash script but I try to verify if the folder exists or not:

BLUE "Installing LS_COLORS..."

if [ ! -d "~/opt/LS_COLORS" ]

then git clone https://github.com/trapd00r/LS_COLORS.git ~/opt/LS_COLORS && cd ~/opt/LS_COLORS cat lscolors.sh >> ~/.bashrc source ~/.bashrc else

    GREEN "LS_COLORS already installed"

fi

The problem is that the LS_COLORS dir does not empty and this is not working properly. I can not get into the else part.

Artur Meinild
  • 26,018

1 Answers1

0

It looks like the path was not correct, I added the full path all the places:

BLUE "Installing LS_COLORS..."
if [ ! -d "/home/torabi12/opt/LS_COLORS/" ]
then
      git clone https://github.com/trapd00r/LS_COLORS.git /home/torabi12/opt/LS_COLORS
      cat /home/torabi12/opt/LS_COLORS/lscolors.sh >> ~/.bashrc
      source ~/.bashrc
else
      GREEN "LS_COLORS already installed"
fi

and now it is working. Thank you for all the replies.