-1
他們, 目前我正在寫一個新手bash文件的工作。唯一的目的是通過單擊來顯示/隱藏隱藏的文件。我最後的劇本是很久很久以前,我研究了這裏的正確的解決方案,並取得了這個腳本:MacOS bash文件如果然後不起作用
#!/bin/bash
if defaults write com.apple.finder AppleShowAllFiles 0
then
defaults write com.apple.finder AppleShowAllFiles 1
else
defaults write com.apple.finder AppleShowAllFiles 0
fi
在此之後沒有正常工作,我想
#!/bin/bash
if defaults write com.apple.finder AppleShowAllFiles 0
then
defaults write com.apple.finder AppleShowAllFiles 1
elif defaults write com.apple.finder AppleShowAllFiles 1
then
defaults write com.apple.finder AppleShowAllFiles 0
fi
好 - 無論是工作部分。因此,如果第一個參數爲true(AppleShowAllFiles 0),它會將該值設置爲1.但是它不會以其他方式工作:Else條件不會執行任何操作。如果AppleShowallFiles 0爲false(意味着AppleShowAllFiles 1),它不會執行任何操作。 爲什麼會這樣,我做錯了什麼,我該如何解決?
我非常感謝任何有用的答案,非常感謝!