Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get file listing for particular date?

Status
Not open for further replies.

jkhatri

Programmer
Mar 13, 2002
2
US
Hello,

I need to write a unix script to get the file listing for all *.rpt files a week ago, 2 weeks ago and a month ago from today's date.

The files are in /home/fnsw/MRII_feeds directory and I am using bourne shell.

For example the search should only give me *.rpt files which are created a week ago.

I am fairly new to unix scripting. Any help would be greatly appreciated.

Thanks!
Jyo

 
very Simple Script Below

#Start script

echo "\nEnter day ..\b\b" # in 1 - 31 format
read day
echo "\nEnter month ...\b\b" # in Jan - Dec format
read month

ls -al |awk '{print $6,$7,$9}'|grep $day|grep $month

#End Script

mike --
| Mike Nixon
| Unix Admin
| ----------------------------
 
Hi,

If you want to list all the files that have been modified since a date ([CC]YYMMDDhhmm.[SS] 08-Mar-2002 00:00 in this example) :

touch -t 200203080000 /tmp/since
find /home/fnsw/MRII_feeds -name '*.rpt' -newer /tmp/since -print
rm -f /tmp/since


The problem is to determine this date.
You can get the date of n days ago with :

OldTZ=$TZ
TZ=GMT-hours # hours = n*24, 7days = 168
SINCE=`date +%Y%m%d0000`
TE=$OldTZ Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top