fileschanged is a GNU/Linux command-line utility that reports when files have been altered.
Go to the Download Area if you want to download the latest version of fileschanged.

This software is a client to FAM (File Alteration Monitor) servers (FAM, Gamin) that is now available in some distributions.  Here's how the fileschanged FAM client works: you give it some filenames on the command line and then it monitors those files for changes.  When it discovers that a file has been altered, it displays the filename on the standard-output.

Here's what the usage looks like:

Usage: fileschanged [OPTION...] [FILE]...
Monitors FILEs for alterations.  Display the filenames of FILEs that were
created, changed, deleted, started execution or finished executing.

  -s, --show=EVENT[,...]     Display created, changed, deleted, executing, or
                             executed files (Default is "created,changed"
  -a, --show-all             Display all file events and the associated action
  -f, --files-to-monitor     (Default) Monitor the FILEs on the command line
  -l, --filelist=FILE        Monitor the list of filenames inside FILE
  -L, --dereference          Don't monitor symlinks, monitor what's pointed to
  -r, --recursive            Monitor subdirectories of directories
  -t, --timeout=N            Delay showing changed files for N seconds (Def=2)
  -p, --display-action       Display action when showing altered files
  -x, --exec=PROG            Run PROG when file altered (PROG action filename)
  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

FILEs must exist when monitoring begins, or they will not be monitored.

Report bugs to <>.

Here are some examples of how you can use fileschanged:

Example 1

Monitoring your home directory for changed files.

[you@localhost you]$ fileschanged -r ~/

...will monitor all files in your home directory, and all directories and subdirectories in it.  For example if you were to receive mail, while you were monitoring your home directory you might see something like:

[you@localhost you]$ fileschanged -r ~/

Example 2

Monitoring your log files.   If a file repeatedly changes, it is repeatedly reported as being changed.  fileschanged doesn't stop monitoring until you hit CTRL-C.

[you@localhost you]$ fileschanged /var/log/messages

...will monitor the log file and whenever it changes, you'll see /var/log/messages listed as the log is updated periodically.

Example 3

Monitoring your kernel source code for changes.

[you@localhost you]$ find /usr/src/linux/ -print | grep "\.[ch]$" | fileschanged -l-

...will monitor all .c and .h files below /usr/src/linux .  If a new .c or .h file is created below /usr/src/linux, fileschanged will NOT monitor it because the find command didn't know about that new file when it ran initially. Notice that the recursive option to fileschanged is not used. That is because the find command supplies the source files to fileschanged. Another way to do it is like this:

[you@localhost you]$ fileschanged -r /usr/src/linux/ | grep "\.[ch]$"

This command will report every changed .c or .h file, including any new source files that are created inside of the /usr/src/linux/ directory.

Example 4

You can also use fileschanged within shell scripts.  Here's a useful one that monitors a directory and archives any new or changed files:

if [ "x$1" == "x" ] ; then
        echo "Usage: `basename $0` "
        exit 1
if [ ! -d $1 ]; then
        echo "ERROR: `basename $0`: $1 is not a directory!"
        exit 2
./fileschanged -r $1 | while read file; do
        tar -uPvf /tmp/tmp.tar $file >/dev/null 2>/dev/null
exit 0

Example 5

You can also use fileschanged as it's own script.  Check out this script called monitor_logs.

#!/usr/local/bin/fileschanged -l

#monitor my web server logs
#monitor XFree86 log for kicks
#we can't monitor /var/log/messages because we don't have permission.
#FAM requires read permission on the file we want to monitor.
#we'd have to run this script as root if we wanted to monitor that log file.

Some (maybe unexpected) limitations of fileschanged:
The remaining options are explained in info page for fileschanged.

Does fileschanged seem useful to you?

For more detailed information, you may wish to consult the User's Manual.

Also visit the fileschanged project on Savannah to submit bugs or to find out more information about fileschanged.