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:


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

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

Hope the above solution works.

Realted Posts : Git crdencial –cache