If else in mac terminal

In this article let’s discuss about If else in mac terminal. Let’s go through the following methods without any delay.

Method 1:

#!/bin/bash

defaultsReturn=$(defaults read com.apple.finder AppleShowAllFiles)

if [ '1' = "$defaultsReturn" ]; then
    echo "AppleShowAllFiles is enabled"
elif [ '0' = "$defaultsReturn" ]; then
    echo "AppleShowAllFiles is not enabled"
else
    echo "defaults returned some other value: $defaultsReturn"
fi

Hope the above solution works.

Realted Posts : Git crdencial –cache