The UNIX and Linux Forums  


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
What to do when mtime doesn't work? bbbngowc Shell Programming and Scripting 19 03-17-2009 10:15 AM
-mtime +30 Blue68 UNIX for Dummies Questions & Answers 1 01-05-2009 02:48 AM
problem in mtime manas_ranjan Shell Programming and Scripting 2 12-24-2007 04:45 AM
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 03:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-24-2009
ss_ss ss_ss is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 58
mtime

Hi,

I've some files of some past days and everyday some new files are also getting added to the same.

Now how can i use mtime to get the files of the current date i.e if i want the files of 25th feb 2009 and if im finding the files on 25th 12:10 am then i should only get the files after 12:00 am of 25th feb 2009.

right now im doing it this way but this gives me the files modified less than 1 day ago i.e., within the past 24 hours, as before.


Code:
find . -name '*.xml' -mtime -1 -exec basename {} \; >>Today.xml

  #2 (permalink)  
Old 02-24-2009
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
A crude but simple way will be:


Code:
touch -t 200902250000 /tmp/newer_than_this
find . -name '*.xml' -newer /tmp/newer_than_this -exec basename {} \; >>Today.xml

Easier than calculating mtime arguments since the -t parameter for touch is much more readable (YYYYMMDDhhmm format). Not sure if the GNU find has friendlier options.
  #3 (permalink)  
Old 02-25-2009
ss_ss ss_ss is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 58
I cant hardcode the timestamp as at any point of time of any day the script will be run and then it needs to search for the current day's files.
  #4 (permalink)  
Old 02-25-2009
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
Show a little initiative in doing some research. (sigh) here goes:


Code:
touch -t `date "+%Y%m%d0000"` /tmp/newer_than_this

  #5 (permalink)  
Old 02-25-2009
ss_ss ss_ss is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 58
thnx a lot.

now getting the desired output :-)
Closed Thread

Bookmarks

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 11:41 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