The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
change created and modification time if symbolic links avanigadhai Filesystems, Disks and Memory 1 02-28-2008 01:07 AM
Copying files created after a specified date/time jm6601 Shell Programming and Scripting 2 11-28-2007 09:29 AM
List files created between specific date and time jazjit Shell Programming and Scripting 3 04-26-2007 10:19 PM
query for a file created at a particular time ragha81 Shell Programming and Scripting 2 01-26-2007 07:49 AM
Determine date and time the file was created through shell scripts BharatSurana Shell Programming and Scripting 1 01-11-2006 09:06 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-22-2007
Registered User
 

Join Date: Dec 2006
Posts: 9
File created time

I have lot .log files in a directory.I need to take the one got created today.Is there any way to get the time of creation of a file?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-22-2007
Registered User
 

Join Date: Feb 2007
Location: Boston, MA
Posts: 64
Quote:
Originally Posted by yakyaj
I have lot .log files in a directory.I need to take the one got created today.Is there any way to get the time of creation of a file?
Use "ls" with "-t" option.
Reply With Quote
  #3 (permalink)  
Old 03-23-2007
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 758
time of creation of files in not stored in UNIX. you may use time of modification instead.

ls -ltr lists the most recently modified files at the bottom

-l long listing
-t sort by modification time
-r reverse the order of sorting
Reply With Quote
  #4 (permalink)  
Old 03-23-2007
Registered User
 

Join Date: Mar 2007
Location: Chennai
Posts: 222
Assume we are creating file with modification times as,

touch -mt 200703231930.22 t4
touch -mt 200703232130.22 t3
touch -mt 200703231230.22 t1
touch -mt 200703201230.22 t2

Now Let us ensure the time stamp of the files,
ls -ltr t*
-rw-r----- 1 usera groupa 0 Mar 20 12:30 t2
-rw-r----- 1 usera groupa 0 Mar 23 12:30 t1
-rw-r----- 1 usera groupa 0 Mar 23 2007 t4
-rw-r----- 1 usera groupa 0 Mar 23 2007 t3


Now using the find command,as below u can list out the files modified within 1 day

find . -name '*' -mtime -1 -ls
1498976 0 -rw-r----- 1 usera groupa 0 Mar 23 12:30 ./t1
1499624 0 -rw-r----- 1 usera groupa 0 Mar 23 2007 ./t3
1500510 0 -rw-r----- 1 usera groupa 0 Mar 23 2007 ./t4

Please check if this works in your case.

Thanks
Nagarajan Ganesan.
Reply With Quote
  #5 (permalink)  
Old 03-23-2007
Registered User
 

Join Date: Dec 2006
Posts: 9
Many thanks for your replies.I tried find but the problem is it will list all the files that got modified for the past one day.I want only files created on that particular day.Am doing a grep for date for that day to get it.Dont know it is good or bvetter ways are there.

Once again many thanks for your help
Reply With Quote
  #6 (permalink)  
Old 03-23-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,465
Code:
find /path/to/files -type f -mtime -1
list files in the directory /path/to/files that were last modified 23:59:59 and less, ie. the last day.
Reply With Quote
  #7 (permalink)  
Old 03-23-2007
Registered User
 

Join Date: Oct 2002
Posts: 670
Unix does not track the creation date of files. For a good explanation, see Perderabo's thread:

http://www.unix.com/tips-tutorials/20526-mtime-ctime-atime.html#post79750
Reply With Quote
Google UNIX.COM
Reply

Tags
mtime

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0