답변:
파일을 열 때 (또는 다른 경우) 스크립트를 실행할 수도있는 경우 opensnoop을 사용할 수 있습니다.
~ / 테스트 :
#!/bin/bash
while :; do
opensnoop | grep -Ev ' (mdworker|mds|filecoordinatio|revisiond|Finder|Alfred) ' | grep -m1 '/Users/username/Folder/.*\.txt'
say a
sleep 1
done
/Library/LaunchAgents/test.plist :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
<key>Label</key>
<string>test</string>
<key>Program</key>
<string>/Users/username/test</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
chmod +x ~/test
, sudo chown root /Library/LaunchAgents/test.plist
, 및 launchctl load /Library/LaunchAgents/test.plist
.