The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mtime ravi raj kumar Shell Programming and Scripting 7 03-01-2007 08:54 PM
mtime help!!!!! scooter17 UNIX for Dummies Questions & Answers 2 09-12-2006 02:24 PM
find . -mtime topcat8 UNIX for Dummies Questions & Answers 1 04-26-2006 10:55 AM
find -mtime off by one day? ceanntrean UNIX for Dummies Questions & Answers 4 08-24-2005 07:46 PM
mtime vs ctime moxxx68 UNIX for Dummies Questions & Answers 3 11-06-2004 10:57 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-17-2007
bbbngowc bbbngowc is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 194
What to do when mtime doesn't work?

I have a folder that I need to search for new files and copy on the latest. I've been using "-mtime -1" in my command line but it doesn't seem to work.

I've been meaning to fine a different script because files are dropped into the folder all day long and because of the -mtime, I've only be able to look for files once a day.

Does someone have a better way for me to search this folder throughout the day to find and copy only the latest files?
  #2 (permalink)  
Old 12-17-2007
idle idle is offline
Registered User
  
 

Join Date: Oct 2007
Location: Wellington, New Zealand
Posts: 30
can you post the full command line?

I'm guessing you're using 'find'.
  #3 (permalink)  
Old 12-17-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Have a cron job that does a listing of the directory and compares the results with the previous listing?

You can also use "ls" to sort files by timestamp.
  #4 (permalink)  
Old 12-17-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
Or touch a file at the end of each collection and simply gather the files newer than the file you touched the next time, then touch the file again.
  #5 (permalink)  
Old 12-17-2007
bbbngowc bbbngowc is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 194
Here's the command:

find . -type f -name "raw_file_*" -mtime -1 | cpio -iv <new directory>

The problem is, when I run this it copies ALL the files in the directory instead of those that are created in 1 day or less. It's crude, cause what I really need is something to look for only NEW files and copy those.
  #6 (permalink)  
Old 12-17-2007
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
Many versions of the find command have an option called -newer which can be used to find files which are newer than the date of a reference file. See the find(1) man page for further information.
  #7 (permalink)  
Old 12-17-2007
bbbngowc bbbngowc is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 194
Quote:
Originally Posted by reborg View Post
Or touch a file at the end of each collection and simply gather the files newer than the file you touched the next time, then touch the file again.
So at the end of the script, have the script touch the same file again?
Closed Thread

Bookmarks

Tags
cpio, mtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0