Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Find the count of files by last created date based on the given date range Post 302937152 by balajesuri on Wednesday 4th of March 2015 02:12:18 AM
Old 03-04-2015
  1. It is not possible (as per POSIX standards) to access the creation date/time of a file. Check this link
    Quote:
    Each file has three distinct associated timestamps: the time of last data access, the time of last data modification, and the time the file status last changed. These values are returned in the file characteristics structure struct stat.
  2. You could try looking at the -mtime option. Here you cannot specify dates, but you should specify the number of days. You could do a little maths to find this out.

Last edited by rbatte1; 03-04-2015 at 07:42 AM.. Reason: Converted to LIST=1 tags from plain text & corrected spelling
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File management based on date created

Hi There, I was wondering how to manage files (ie. rm, cp , mv) based on date last modified and date created. ie. Say i want to: mv ./* ./temp/* (where the date created < 29/1/2006 ) or mv ./* ./temp/* (where the date modified > 27/1/2006 && date modified < 29/1/2006) Thanks in... (1 Reply)
Discussion started by: Geehog_Rare
1 Replies

2. Shell Programming and Scripting

Count of files based on date?

Hi Friends, Can anyone help me with this: To get the count of files that are existing in a directory created on a perticular date like in the example (01/08) .(having same pattern for the filename) ex: FileName Creted Date FILE001 01/08/2007 FILE005 ... (6 Replies)
Discussion started by: sbasetty
6 Replies

3. Shell Programming and Scripting

Rename File Based on Created Date

I am trying to rename files based on the created/born date of the file. I Have a total of 4000 files that i am trying to do this with and would like it to be log_yyyymmddhh.gz right now the files are maillog.???.gz. Can anyone point me in the right direction of how to get this done via scipt? ... (4 Replies)
Discussion started by: Paulb
4 Replies

4. Shell Programming and Scripting

Need script to select multiple files from archive directory based on the date range

hi all, here is the description to my problem. input parameters: $date1 & $date2 based on the range i need to select the archived files from the archived directory and moved them in to working directory. can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Discussion started by: bbc17484
3 Replies

5. Shell Programming and Scripting

Copy files based on last created date

Hi, I have a requirement to copy files from a windows network drive to a Linux server using shell script based on the last created date. Ex: FileName CreatedDate/Time F1 05-01-2012 3:00 PM F2 05-01-2012 3:15 PM F3 05-01-2012 2:00 PM When i run the shell script... (1 Reply)
Discussion started by: Lee_10
1 Replies

6. Shell Programming and Scripting

Find and copy files based on todays date and search for a particular string

Hi All, I am new to shell srcipting. Problem : I need to write a script which copy the log files from /prod/logs directory based on todays date like (Jul 17) and place it to /home/hzjnr0 directory and then search the copied logfiles for the string "@ending successfully on Thu Jul 17". If... (2 Replies)
Discussion started by: mail.chiranjit
2 Replies

7. Shell Programming and Scripting

Find and count unique date values in a file based on position

Hello, I need some sort of way to extract every date contained in a file, and count how many of those dates there are. Here are the specifics: The date format I'm looking for is mm/dd/yyyy I only need to look after line 45 in the file (that's where the data begins) The columns of... (2 Replies)
Discussion started by: ronan1219
2 Replies

8. UNIX for Dummies Questions & Answers

Unable to find files, those can be present anywhere in the directory tree,based on its creation date

Hi I am unable to find files, those are present anywhere in the same directory tree, based on the creation date. I need to find the files with their path, as I need to create them in another location and move them. I need some help with a script that may do the job. Please help (2 Replies)
Discussion started by: sam192837465
2 Replies

9. Red Hat

Find Files within date Range

Hi i am looking to expand a command i am using to find files in a large file system. i am currently using find /raid/JOBFLOW_LOCKED/ -type f -size +3G | -exec mv {} /raid/JOBFLOW_LOCKED/KILL \; This works really well but i would like to add a date range to the same command to refine it... (6 Replies)
Discussion started by: treds
6 Replies

10. UNIX for Beginners Questions & Answers

Find the files based on date from filelist

Hi All, I have a filelist which contains the "ls" output, i want to extract the filenames written in this files based on date. I know i can run loop and extract the file but i want to avoid it. also there is find command which can be used on directory i.e. find . -type f -newermt "2019-09-25"... (3 Replies)
Discussion started by: kumarinfa
3 Replies
utime(2)							System Calls Manual							  utime(2)

NAME
utime, utimes - Sets file access and modification times SYNOPSIS
#include <sys/time.h> #include <utime.h> #include <sys/types.h> int utime ( const char *path, const struct utimbuf *times ); int utimes ( const char *path, const struct timeval times[2]; The following definition of the utime() function does not conform to current standards and is supported only for backward compatibility (see standards(5)): int utime ( const char *path, struct utimbuf *times ); int utimes ( const char *path, struct timeval times[2]; STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: utime(), utimes(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the file. If the final component of the path parameter names a symbolic link, the link will be traversed and pathname resolution will continue. Points to a utimbuf structure for the utime() function, or to an array of timeval structures for the utimes() function. DESCRIPTION
The utimes() function sets the access and modification times of the file pointed to by the path parameter to the value of the times parame- ter. The utimes() function allows time specifications accurate to the microsecond. The utime() function also sets file access and modification times; however, each time is contained in a single integer and is accurate only to the nearest second. For utime(), the times parameter is a pointer to a utimbuf structure, defined in the utime.h header file. The first structure member repre- sents the date and time of last access, and the second member represents the date and time of last modification. The times in the utimbuf structure are measured in seconds since the epoch (00:00:00, January 1, 1970, Coordinated Universal Time (CUT)). For utimes(), the times parameter is an array of timeval structures, as defined in the sys/time.h header file. The first array element represents the date and time of last access, and the second element represents the date and time of last modification. The times in the timeval structure are measured in seconds and microseconds since the epoch, although rounding toward the nearest second may occur. If the times parameter is null, the access and modification times of the file are set to the current time. If the file is a remote file, the current time at the remote node, rather than the local node, is used. The effective user ID of the process must be the same as the owner of the file, or must have write access to the file or superuser privilege in order to use the call in this manner. If the times parameter is not null, the access and modification times are set to the values contained in the designated structure, regard- less of whether those times correlate with the current time. Only the owner of the file or a user with superuser privilege can use the call this way. Upon successful completion, the utime() and utimes() functions mark the time of the last file status change, st_ctime, for update. RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. Otherwise, a value of -1 is returned, errno is set to indicate the error, and the file times will not be affected. ERRORS
If the utimes() or utime() function fails, errno may be set to one of the following values: Search permission is denied by a component of the path prefix; or the times parameter is null and effective user ID is neither the owner of the file nor has appropriate system privi- lege, and write access is denied. The path parameter is an invalid address, or (for utimes()) either the path or times parameter is an invalid address. The file is not a regular file. Too many links were encountered in translating path. The length of the path parameter exceeds PATH_MAX or a pathname component is longer than NAME_MAX. The named file does not exist or the path parameter points to an empty string. A component of the path prefix is not a directory. The times parameter is not the null value and the calling process has write access to the file but neither owns the file nor has the appropriate system privilege. The file system that contains the file is mounted read-only. The process' root or current directory is located in a virtual file system that has been unmounted. The utimes() function can also fail if additional errors occur. RELATED INFORMATION
Functions: stat(2) Standards: standards(5) delim off utime(2)
All times are GMT -4. The time now is 10:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy