The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
How can i copy files by date last modifed range? geauxsaints UNIX for Advanced & Expert Users 4 05-25-2008 11:06 AM
How to display files that have been modifed between a given date range prathima UNIX for Dummies Questions & Answers 1 04-02-2008 11:24 AM
automated ftp script from unix -date range of files koduri0475 Shell Programming and Scripting 1 11-10-2005 10:50 AM
cp only files in certain date range ee7klt UNIX for Dummies Questions & Answers 1 06-27-2005 09:35 PM
Moving Files within a particular date range rooh UNIX for Dummies Questions & Answers 3 03-18-2002 10:59 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-05-2007
zcanji zcanji is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 3
Search files between a date range

Hi people

A newbie here, thrown into the deep end. I want to select the group of files with in a range of dates and perform some operation on it. Are there inbuild date libraries i can use?

I did read thru the old posts on this topic. Couldnt get much idea , basically want to know how I can increment the dates or how unix does that, date formats (ddmmyy, dd MM yyyy, etc.), etc. I reckon the solution would be to find the right switched with 'find'. Pl help.

Thanx
  #2 (permalink)  
Old 09-05-2007
younggun younggun is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 13
you can use touch and find implement it.
  #3 (permalink)  
Old 09-05-2007
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
You can use find command in this.
just do a
man find
and go through that,it will solve ur problem.

Thanks
Namish
  #4 (permalink)  
Old 09-05-2007
zcanji zcanji is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 3
date formats

yup thanx. i figured that out. im using somehting like this -

touch -d "$1" ./tmp1
touch -d "$2" ./tmp2
find -name '*.cdr' -newer ./tmp1 ! -newer ./tmp3

1. I'm required to have the start/end dates in the format ddmmyyyy but touch seems to take only dd MMM or dd MMM yyyy. Can change/set the date format??

2. '-newer' retreives the file created *after* creation date on tmp1. I want to search for the files created *on or after* creation of tmp1. how would I do that?

Thanx ppl.
  #5 (permalink)  
Old 09-05-2007
younggun younggun is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 13
1.touch only can accept its own time format, so you may adjust you to fit it. use -t parameter can adjust to minute(or second, it determind by your OS)
2.in fact, '-newer' retreives the file *on or after*, you can try it on your machine.

btw: what's ppl?
  #6 (permalink)  
Old 02-07-2009
hawstom hawstom is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 1
ppl means people. :-) Here is how I did a limited date range file search

The snippet below finds files modified between 2500 and 2800 minutes ago.

Code:
find -cmin +2500  -cmin -2800
The snippet below finds files modified between 20 and 21 days ago.

Code:
find -ctime +20  -ctime -21
I, too, am a hopeless newbie, but those worked for me.

Tom
  #7 (permalink)  
Old 05-27-2009
tonan tonan is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 11
#!/bin/ksh
#################################################
## File: findDateRange.sh
## Date: May 27, 2008
## Author: Saurav Sen
## Purpose: A script to find the files within
## a given date range
#################################################
echo "You have to provide the path, start date and the end date"
echo
echo "Enter the path to start search"
read fpath
echo "Please enter the start date in the format YYYYMMDD"
read strtdt
echo "please enter the end date in the format YYYYMMDD"
read enddt
touch -t ${strtdt}0000 /tmp/newerstart
touch -t ${enddt}2359 /tmp/newerend
#find ./ \( -newer /tmp/newerstart -a \! -newer /tmp/newerend \) -print
find $fpath \( -newer /tmp/newerstart -a \! -newer /tmp/newerend \) -exec ls -l {} \;
Sponsored Links
Reply

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 07:10 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