permaculture playing cards*
The moose likes Linux / UNIX and the fly likes Selection of only modified files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Selection of only modified files" Watch "Selection of only modified files" New topic

Selection of only modified files

Timmy Gupta

Joined: Dec 06, 2008
Posts: 6
I need to create a shell script to move only modified files with the exact folder structure to another place. Could anyone please tell me how to distinguish the modified files?

Think before you speak as you might hurt or break someone's heart.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959

Linux doesn't keep a "modified" flag for files - it keeps a timestamp. The DOS "modified" bit was handy for a single-user-system - the backup programs could set/reset it. But the Unix people tend to do things that are more devious.

There are a couple of options.

1. Check the original date against the change (modified) date. However, unlike the DOS Modified flag, there's no way to switch this off after you've done whatever operation is interested in modified files. Once modified, it's "modified" forever.

2. Check the change date against an absolute date. A number of *n*x utilities, including find and tar can do that, as well as bash builtin functions. This is what's usually used for incremental or differential backups.

There's also some tricks that involve keeping inventory of dates, but they're more specialized.

Customer surveys are for companies who didn't pay proper attention to begin with.
jQuery in Action, 2nd edition
subject: Selection of only modified files
Similar Threads
Getting only modified from vss using ant scripts
ant with smartCVS
About websphere xa datasource
Database Connection and Operations
Configuration management of JBoss files