我正在尝试编写一个脚本,该脚本将在 Finder 中显示和隐藏隐藏文件之间切换,但遇到错误:
./HiddenFileToggle: line 1: [defaults: command not found
if [defaults read com.apple.finder AppleShowAllFiles]
then
defaults write com.apple.finder AppleShowAllFiles TRUE
else
defaults write com.apple.finder AppleShowAllFiles FALSE
fi
killall Finder
最佳答案
将命令括在反引号中`
:
`defaults read com.apple.finder AppleShowAllFiles`
关于macos - 如何在 Mac 上的终端脚本的 if 语句中使用命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16420659/