# File Modification Monitor

**URL:** <https://www.ruby-forum.com/t/file-modification-monitor/123219>\
**Category:** Ruby\
**Created:** [December 15, 2007, 12:06am UTC](https://www.ruby-forum.com/t/file-modification-monitor/123219 "2007-12-15T00:06:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlimited](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed655f/32.png) [@jlimited](https://www.ruby-forum.com/u/jlimited)\
**Post date:** [December 15, 2007, 12:06am UTC](https://www.ruby-forum.com/t/file-modification-monitor/123219/1 "2007-12-15T00:06:12Z")

</div>

Hello,

I am new to ruby. I have a thrid party application that stores  
configuration settings in an ASCII/TEXT file. I need to map each  
function within the application to what lines it modifies in the text  
file. Every time I save the session, it creates a \*.bak\_YYMMDDHHmmss of  
the previous version of the file.

I am looking to develop a simple script that I would loop through a  
directory and then compare the oldest \*.bak\_YYMMDDHHmmss with the next  
newest \*.bak\_YYMMDDHHmmss, until it reached the newest file. The script  
would append the differences to a text file.

A nice to have is a start and stop funcation, where I could have it  
watch a directory and when ever a new \*.bak\_YYMMDDHHmmss file appears it  
will compare the files.

I am looking for resoucres on how to program this script.

Thanks  
jlimited

---

<div class="post-metadata">

**Author:** ![jlimited](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed655f/32.png) [@jlimited](https://www.ruby-forum.com/u/jlimited)\
**Post date:** [December 17, 2007, 3:33pm UTC](https://www.ruby-forum.com/t/file-modification-monitor/123219/2 "2007-12-17T15:33:58Z")

</div>

On 14 Dec 2007, at 23:06, Travis Gassmann wrote:

> A nice to have is a start and stop funcation, where I could have it  
> watch a directory and when ever a new \*.bak\_YYMMDDHHmmss file  
> appears it  
> will compare the files.
> 
> I am looking for resoucres on how to program this script.

You might Autotest’s code instructive. It watches a directory (of  
test files) and triggers whenever it spots a change.

> **[zentest | software projects | by ryan davis](https://www.zenspider.com/projects/zentest.html)**
>
> autotest and much more

For file comparison diff-lcs should be more than enough:

[http://raa.ruby-lang.org/project/diff-lcs/](http://raa.ruby-lang.org/project/diff-lcs/)

Regards,  
Andy S.
