Can I use `cp` in bash to watch files and folders and upon changes, copy them other to another folder?
13:45 24 Mar 2021

Update

Okay, I've got inotify going, but I'm not sure how to pipe it into cp.

I can run inotifywait -rm source/ and it will print to the terminal when changes happen to the file or new files are created and so forth.

Now I need to listen to when any change happens and just run cp -u source/* destination/

How do I do this in bash in one line?

Old stuff below here...

I'm using the cp command to copy files for my static site builder. I'm trying to also create a watch feature.

Can I use cp to somehow watch a file or folder full of files and other nested folders of files, and upon any saved changes to those files and folders copy them to a destination folder, effectively syncing one directory to another?

Or rsync or another command line tool?

linux terminal rsync cp