Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Ich lerne gerade für eine Prüfung und finde keinen command der mir erlaubt einen Pfad nach der existenz zu prüfen.

ich hab das hier unten ausprobiert mit "test" aber dies funktioniert wohl nicht.

 

kann mir bitte jemand weiterhelfen?

if test $homepath -eq true
then

    echo "Path is Here"
    
else

    echo "Path is not Here"
    
fi

 

 

Schau hier: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

bzw. http://wiki.bash-hackers.org/commands/classictest

 

Das was du brauchst ist "-d" ( True if FILE exists and is a directory. )

if test -d $homepath        das "-eq" ist hier fehl am Platz, das wird für integers verwendet. Du verwendest jedoch einen string, da könntest du ggf. mit "=" arbeiten, aber dann würdest du halt mit dem Wort (string) "true" vergleichen.

Der Test "if test -d $homepath" prüft, ob das Verzeichnis $homepath vorhanden ist - falls ja, wird ein returm code mit dem Wert 0 (= true) zurückgegeben, und die Bedingung ist erfüllt.

Das hier geht auch:

if [ -d $homepath ]       (Achte auf die beiden Leerzeichen in den eckigen Klammern am Anfang + Ende! Das kenne ich eher als "gängige" Schreibweise. Aber das "[" ist im Prinzip nur ein anderer Ausdruck für "test", Erklärung siehe zweiter Link).

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.