Visit Our UNIX and Linux User Community

Files between two dates in UNIX

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Files between two dates in UNIX
# 1  
Old 07-01-2014
Files between two dates in UNIX

Hi Team,

I need to connect to a prod server and need to get the files which falls between two dates. I should not create ant files on that machine.
I am using korn shell.

Your help is very much appreciated.

# 2  
Old 07-01-2014
So a few questions first:-
  • What have you tried so far?
  • What errors/output are you getting?
  • What OS and version are you using?
  • What tools do you prefer?
Most importantly, What have you tried so far?

If you were to consider the problem as a manual tasks, break it down into smaller chunks and logically work out the simplest steps you can. Does that help?

Show us your efforts and thinking and we will be better placed to help you.

# 3  
Old 07-01-2014
man find
# 4  
Old 07-01-2014
I have gone through man pages of Find and explored a option . But I cannot use this option as I don't have permission create any files on remote server.
Here is the option which I have seen in Man pages
$touch -t yyyymmddHHMM start_date_file
$ touch -t yyyymmddHHMM end_date_file
find . -type f -newer yyymmddHHMM ! -newer yyymmddHHMM -exec
# 5  
Old 07-01-2014
Try this (from the FAQ forum).
# 6  
Old 07-02-2014
Hi I need to search in sub-directories also. I removed maxdepth option from the command but it is not working.
find . -daystart -mtime $(( -1-$(date +%j)+$(date --date '08 Oct' +%j))) ! -mtime $(( -$(date +%j)+$(date --date '10 Oct' +%j)))

I need to exclude directories in the above file list

Last edited by Franklin52; 07-02-2014 at 11:57 AM.. Reason: Please use code tags
# 7  
Old 07-02-2014
Is it just the exclude directories part that is causing it to not work or do you get some error or other - please expand on not working.

For excluding directories try ! -type d

Previous Thread | Next Thread
Test Your Knowledge in Computers #398
Difficulty: Medium
HP-UX offers operating system-level virtualization features such as hardware partitions, isolated OS virtual partitions on cell-based servers, and HP Integrity Virtual Machines (HPVM) on all Integrity servers.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need to Move files of different dates

Hi, Currently I'm moving the files based on date like below. "mv *20150901* backup_folder" - Limitation: can move only 1 day files to backup folder. I want to move the files of different dates like 20150901,02, 03, 04..... Is there any single command to do it. Thanks in advance!! (2 Replies)
Discussion started by: prakashs1218
2 Replies

2. Shell Programming and Scripting

Deleting the files between particular dates

Hi Please help me for the below task. In my home directory if I run ls -l command, it lists all the files, here I want to delete files created from January 2014 to Aug 2014...but I need to keep the files which are created after September 01 2014. Thanks Siva (3 Replies)
Discussion started by: kumar85shiv
3 Replies

3. UNIX for Advanced & Expert Users

Find all files other than first two files dates & last file date for month

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (16 Replies)
Discussion started by: Makarand Dodmis
16 Replies

4. AIX

Copy files for particular dates

Hi, I need to copy particular date files from one directory to another. For example, I have thousands of files in /home/usr From this I need to copy only particular date files (each date contains thousand number of files) to some directory of another server. Could anyone please help me... (3 Replies)
Discussion started by: teddy2882
3 Replies

5. Shell Programming and Scripting

Compare 2 dates in unix

I have 2 variables in my script like this $v_last_update_date1 = 08/18/2009 08:41:17 $v_last_update_date2 = 08/18/2009 08:30:17 Now I want to comapre with greater than if then go forward else error and exit out I am getting unknown test operator error Can anyone advise (1 Reply)
Discussion started by: veeru
1 Replies

6. UNIX for Dummies Questions & Answers

UNIX Dates

Hey guys. I need to manipulate the system date to move forward a day. So, if the system date was 02/14/08, I need the 'new' date to be 02/15/08 so my script will look for the date of 02/15/08. The thing is the file I will be looking for always has the date of the next day. Any ideas, ... (9 Replies)
Discussion started by: ndoggy020
9 Replies

7. UNIX for Dummies Questions & Answers

files between any two given dates

Can any one help me in getting all the files between any two given dates.. (8 Replies)
Discussion started by: thanuman
8 Replies

8. UNIX for Dummies Questions & Answers

Files and dates

Hello all. I am trying to do a file listing on a particular directory by date. I need to list the files and their directories that have a timestamp between Dec-1-2006 and Jan-1-2007. Any help would be greatly appreciated. (1 Reply)
Discussion started by: mastachef
1 Replies

9. UNIX for Dummies Questions & Answers

Need help with Unix dates

I'm very new to Unix, so forgive me for what will probably be a very quick fix. I have the following in a ksh script. Its purpose is to return yesterday's date. The $DAY part is coming back with a '2' but I need it to return as '02'. How can I do that? date '+%b %d %Y' | { read MONTH DAY... (4 Replies)
Discussion started by: ssmiths001
4 Replies

10. UNIX for Dummies Questions & Answers

Unix dates

How can I use the date function to get the following format? Nov 18 I've tried date +%b%d but I get it in this format: Nov18 with no space. (1 Reply)
Discussion started by: ssmiths001
1 Replies

Featured Tech Videos