Find the count of files by last created date based on the given date range


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find the count of files by last created date based on the given date range
# 1  
Old 03-04-2015
Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1

I tried google my requirement and found the below answer,

Code:
find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20"

But newer command is not working in AIX version 6.1 unix

I have given my requirement below:

Input:
Code:
atr files:

file_atr1.txt     --created on feb 01 2015
file_atr2.txt    --created on feb 10 2015
file_atr3.txt    --created on feb 16 2015

ses files:

file_ses1.txt    --created on feb 01 2015
file_ses2.txt    --created on feb 10 2015
file_ses3.txt    --created on feb 16 2015

I need to get the count of two files separately based on date range. If the count matches then, I should set the flag as 'Y' else 'N'

For eg: I am giving the date range as start date: feb 01 2015 and end date: feb 15 2015, i should be getting 2 files
from atr file list and 2 files from ses file list for the date range mentioned above.Since the count of two file list matches then the flag should be set as 'Y'

Output:
Code:
atr files:

file_atr1.txt     --created on feb 01 2015
file_atr2.txt    --created on feb 10 2015

ses files:

file_ses1.txt    --created on feb 01 2015
file_ses2.txt    --created on feb 10 2015

Count of atr files: 2
Count of ses files: 2

Out_Flag = 'Y'

Moderator's Comments:
Mod Comment
Please wrap all code, files, input & output/errors in CODE tags.
It makes the easier to read and preserves multiple spaces.

I've had to guess at where to mark the input & output so adjust it if required.
Press the Edit button in the bottom right of this post

Last edited by rbatte1; 03-04-2015 at 07:41 AM.. Reason: Added CODE tags and corrected spelling
# 2  
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question