![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
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. |
|
||||
|
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? |
|
||||
|
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 Code:
find -ctime +20 -ctime -21 Tom |
|
||||
|
#!/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 | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|