I prepared a little bash script to toggle the visibility of my hidden OS X files.if (defaults write com.apple.finder AppleShowAllFiles FALSE); then    defaults write com.apple.finder AppleShowAllFiles TRUEelif (defaults write com.apple.finder AppleShowAllFiles TRUE); then    defaults write com.apple.finder AppleShowAllFiles FALSEfikillall FinderWhen hidden files are invisible, the script successfully makes them visible but afterwards, when I re-run the script to make the hidden files invisible again, it fails and does nothing.Where am I going wrong?
Bash script to hide/show files
bash;shell script;files;osx;osx finder
In the if conditions you should use the defaults read command, and not write. Otherwise the result is always true and of course the elif never runs. Also, that is not the syntax for if conditions. You should use:if [ $(command) == TRUE ]; thenBut in this case, perhaps something like this would be less verbose:STATUS=$(defaults read com.apple.finder AppleShowAllFiles)case $STATUS in    TRUE) OPTION=FALSE ;;    FALSE) OPTION=TRUE ;;esacdefaults write com.apple.finder AppleShowAllFiles $OPTIONkillall Finder