Monitor changed files into a log file, with day rotation, using fswatch (MacOS)

fswatch --exclude=.git/* --exclude=.settings --event-flags --event-flag-separator=\; -t -f '%Y-%m-%d %H:%M:%S' . >> ./.file_changes_$(date +"%Y-%m-%d" | sed s/-//g).log
This command monitors changes in the current folder structure (subfolders included) and files, and log it into a hidden file in the same folder, called `.file_changes_YYMMDD.log`. Modify the `--exclude` parameters to define what should be skipped.
Sample Output
2023-08-18 00:52:50 /Users/thatsme/test/battery.png IsFile
2023-08-18 00:52:50 /Users/thatsme/test/battery.png Created;AttributeModified;IsFile
2023-08-18 00:52:50 /Users/thatsme/test/check-mark.png IsFile
2023-08-18 00:52:50 /Users/thatsme/test/check-mark.png Created;AttributeModified;IsFile
2023-08-18 00:52:50 /Users/thatsme/test/image-20230411-145835.png IsFile
2023-08-18 00:52:50 /Users/thatsme/test/image-20230411-145835.png Created;AttributeModified;IsFile
2023-08-18 00:52:50 /Users/thatsme/test/image.png IsFile
2023-08-18 00:52:50 /Users/thatsme/test/image.png Created;AttributeModified;IsFile
2023-08-18 00:52:50 /Users/thatsme/test/rss.png IsFile
2023-08-18 00:52:50 /Users/thatsme/test/rss.png Created;AttributeModified;IsFile
2023-08-18 00:54:04 /Users/thatsme/test/images Created;IsDir
2023-08-18 00:54:07 /Users/thatsme/test/Retro 2 - 2023-08-02_2023-08-02_11-47-53.png IsFile;Renamed
2023-08-18 00:54:07 /Users/thatsme/test/images/Retro 2 - 2023-08-02_2023-08-02_11-47-53.png IsFile;Renamed
2023-08-18 00:54:07 /Users/thatsme/test/agile team campers.png IsFile;Renamed
2023-08-18 00:54:07 /Users/thatsme/test/images/agile team campers.png IsFile;Renamed
2023-08-18 00:54:07 /Users/thatsme/test/battery.png IsFile;Renamed
2023-08-18 00:54:07 /Users/thatsme/test/images/battery.png IsFile;Renamed
2023-08-18 00:54:07 /Users/thatsme/test/check-mark.png IsFile;Renamed

1
By: paulera
2023-08-17 23:06:30

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: