bashでファイルをウォッチしたい
#!/bin/bash FILE="$1" CMD="$2" LAST=`ls -l "$FILE"` while true; do sleep 1 NEW=`ls -l "$FILE"` if [ "$NEW" != "$LAST" ]; then "$CMD" "$FILE" LAST="$NEW" fi done linux - Shell command to monitor changes in a file - Server Fault
mac では `sleep 1m` は機能しない。秒数のみ。
This post is licensed under CC BY 4.0 by the author.