How can i get last week files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can i get last week files
# 1  
Old 06-03-2010
How can i get last week files

Hi,
Is it possible to get all the files modified in the last week (Not before or after that week) . I have tried with date range it works for me for the period of seven days , not exactly for weekly basis .
Fetching records for seven day by
Code:
find -mtime +6 -a -mtime -13

As today date is 3rd June , it should fetch files modified of date range 23rd to 29th of May.

thanks
posix..
# 2  
Old 06-03-2010
I think that will give you proper results:
Code:
find . -daystart -mtime +6 -a -mtime -13

# 3  
Old 06-03-2010
sorry , it's not help full for me
Code:
$ls -ltr
total 20
-rw-r--r-- 1 root root    0 May 18 23:15 jd15234
-rw-r--r-- 1 root root    0 May 19 23:15 je13795
-rw-r--r-- 1 root root    0 May 20 23:15 jkl
-rw-r--r-- 1 root root   29 May 21 00:20 rd11673
-rw-r--r-- 1 root root    0 May 21 23:15 ka12684
-rw-r--r-- 1 root root    0 May 22 23:15 kb27948
-rw-r--r-- 1 root root    0 May 23 23:15 kc27447
-rw-r--r-- 1 root root    0 May 24 23:15 kd31910
-rw-r--r-- 1 root root    0 May 25 23:15 ma6198
-rw-r--r-- 1 root root    0 May 26 23:15 mb21233
-rw-r--r-- 1 root root    0 May 27 23:15 mc2490
-rw-r--r-- 1 root root    0 May 28 23:15 md8924
-rw-r--r-- 1 root root    0 May 29 23:15 me9158

Date range is not the last week range..
Code:
$find . -daystart -mtime +6 -a -mtime -13 -exec ls -l {} \;
-rw-r--r-- 1 root root 0 May 24 23:15 ./kd31910
-rw-r--r-- 1 root root 0 May 26 23:15 ./mb21233
-rw-r--r-- 1 root root 0 May 23 23:15 ./kc27447
-rw-r--r-- 1 root root 0 May 22 23:15 ./xyz/af
-rw-r--r-- 1 root root 0 May 22 23:15 ./kb27948
-rw-r--r-- 1 root root 0 May 27 23:15 ./mc2490
-rw-r--r-- 1 root root 0 May 25 23:15 ./ma6198

Is there any method to track the weekly records?
# 4  
Old 06-03-2010
try adjusting those day parameters. Also check if date on your system is correct with:
Code:
date

# 5  
Old 06-03-2010
This works fine in my environment: 1st day is monday and it's 1, sunday is 7.

Code:
day=$(date +%u) # return 4 in my env (2010-06-03 Thu)
((day1=day-1))
((day2=day+7))
find . -mtime +$day1 -a -mtime -$day2

# 6  
Old 06-03-2010
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Linux

Get all the files from a FTP location with previous week's dates in the file names using Linux

I have a weird requirement where I have to get the files from a FTP(Lets say FTP1) location and place it on my current FTP(Lets say FTP2) location. The issue is, these are daily files (in a pattern Sales_YYYYMMDD_report.csv) and are placed every day on FTP1 and my process usually runs on Monday(eg.... (2 Replies)
Discussion started by: dhruuv369
2 Replies

2. Shell Programming and Scripting

Need help deleting files one week older

Hi, I need to delete *.bad files which are 1 week old. How can I achieve that. I tried doing through below script but it deletes all the files. find ./ -mtime +7 -exec rm *.bad {} \; The below one works but i want to delete only files with .bad extension find . -mtime +7 | xargs rm (2 Replies)
Discussion started by: Gangadhar Reddy
2 Replies

3. UNIX for Advanced & Expert Users

How to pick only current week files?

Hi, My job will run every friday and it should pick only that week files. For Ex: this 24th May job will trigger and it should pick 20,21,22,23,24.and 19th sun and 18th sat we dont have files to pick. currently i am using the below code and it is working fine, but sometimes it is picking... (3 Replies)
Discussion started by: kiranparsha
3 Replies

4. UNIX for Dummies Questions & Answers

Number of files accessed this week

I have looked around on the internet and still i am no wiser as to how to show the number of files in a directory that have been accessed this week and also that as a percentage. Any help would be much appreciated. (5 Replies)
Discussion started by: RAFC_99
5 Replies

5. UNIX for Dummies Questions & Answers

crontab every other week

I have two sets of tapes for each week days. Mon_Set_A ____________Tue_Set_B Tue_Set_A ____________ Tue_Set_B Wed_Set_A ___________ Wed_Set_B Thr_Set_A ____________ Thr_Set_B Fri_Set_A _____________ Fri_Set_B I have script that does cold backup of database and then back up to tape. ... (1 Reply)
Discussion started by: Paul.S
1 Replies

6. Shell Programming and Scripting

Removing files older than one week in a directory

Hi, I need a shell script to remove the files older than a week in a directoy and if necessary to zip the files. (2 Replies)
Discussion started by: sudhakaryadav
2 Replies

7. Shell Programming and Scripting

Get Files from ftp which are uploaded recent week

Hi All, Here is a brief scenario for my requirement .. There is a directory in FTP Server, where would files be uploaded on weekly basic. I need to get those files which are uploaded during this week and not the files which are uploaded the previous week and download them to locale... (1 Reply)
Discussion started by: narramadan
1 Replies

8. Shell Programming and Scripting

How to identify week-1 and week-2

Hello Friends I have three dirs 1. /home/main-bkup 2. /home/bkup-week1 3. /home/bkup-week2 Now we copy backups in 1 initially, then on 1st week we copy few content of 1 into 2 and then run some scripts on that. Then in 2nd week we keep 2 untouched and do the same thing in 3. So I... (1 Reply)
Discussion started by: csaha
1 Replies
Login or Register to Ask a Question