![If-else mit nicht leerem Verzeichnis](https://rvso.com/image/1072586/If-else%20mit%20nicht%20leerem%20Verzeichnis.png)
Ich möchte etwas von GitHub in einem Bash-Skript installieren, versuche aber zu überprüfen, ob der Ordner existiert oder nicht:
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
Das Problem ist, dass das Verzeichnis LS_COLORS nicht geleert wird und dies nicht richtig funktioniert. Ich kann nicht in den anderen Teil gelangen.
Antwort1
Es sieht so aus, als wäre der Pfad nicht korrekt gewesen. Ich habe überall den vollständigen Pfad hinzugefügt:
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
und jetzt funktioniert es. Vielen Dank für alle Antworten.