Linux Tips 9: Find recently modified files

|
Back when I was developing at a company where no version control systems were used and CSV was the pain it still is now, going without a system at all was preferable than trying to get a working CSV system. However as expected I often find my self unable to find some code that has been overridden by a college and would find it difficult to locate the files he had changed.

Luckily find, the Linux command, is quite powerful and can show you a list of all recently modified files. For example, if you come in to work on Monday and found out that a weekend coder was brought in and made some changes without leaving any documentation all you would need to do is type:

find . -mtime -3
The above code will find files that have been modified less than 3 days ago. To be more specific and just check for the file change time, use:

find . -ctime -3
To be even more specific you can set a date range by using:

find . -ctime +1 -a -ctime -3
Which will find all files changed, and thus modified, at least one day ago but within three days ago.

For those wanting to check whether their employees are doing what they said they are, doing this check is also an easy way to see just how many files were updated to implement the "super comprehensive overhaul" that just had to be done.

4 comments:

Meekohi said...

Nice and simple, thanks :)

Zarn700 said...

Thanks for this. Gotta love fast answers via Google. I hit tons of these types of posts per day to cobble together my world that is linux administration. haha... I hardly ever stop to say thanks. But I saw you're a Queenslander and you guys always stop to say something so... Thanks. haha. Enjoy the horrible weather over there.

Tyler said...

Great, just used this when someone hacked my site (experimentsinwandering.com) and I had to check when files were modified to see when the hacker got in and what files were modified. Allowed me to see specific files and get rid of them. I just accessed the SSH to the server through PuTTY, ran these lines, and got rid of the files through FTP. Btw, I had no idea what any of this meant a few hours ago. Thanks for making this so easy.

Danish Backer said...

:D thanks

Post a Comment