Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to find a file that's modified more than 2 days ago but less than 5 days ago? Post 303012838 by Don Cragun on Saturday 10th of February 2018 10:18:05 AM
Old 02-10-2018
If your find doesn't have the -mmin or -daystart primaries (neither of which are specified by the standards), you can also use touch to create two files with the timestamp boundaries you want at each end of your window and use:
Code:
trap 'rm -f /tmp/start_time_file.$$ /tmp/end_time_file.$$' 0

# Note that although the following uses midnight as the start and stop times,
# using touch allows you to set any time range you want.  If you use -d instead
# -t to set timestamps, you can set ranges down to the nanosecond level if the
# filesystems on which the time range files and the file hierarchy being searched
# support timestamps to that level of detail.
touch -t 201802050000 /tmp/start_time_file.$$
touch -t 201802080000 /tmp/end_time_file.$$

find /directory/at/root/of/hierarchy -type f -newer /tmp/start_time_file.$$ ! -newer /tmp/end_time_file.$$

Note: Fixed to consistently use timestamp files created in /tmp and switch end and start files in the find command as noted by RudiC in private mail.

Last edited by Don Cragun; 02-11-2018 at 05:59 AM.. Reason: Make fixes listed in note.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting files created before two days ago

Dear All: I want to build a shell that delete files created two or more days ago ... I think it could be built using a special command with ls or grep, I'd apreciate any help from you guys I have a lot of log files from november, december, january and this tool will help me a lot The files... (3 Replies)
Discussion started by: josecollantes
3 Replies

2. Shell Programming and Scripting

Function 7 days ago

Please tell me how can I wirte a function to return the date 7 days ago by using calendar command? :confused: (2 Replies)
Discussion started by: LAY
2 Replies

3. UNIX for Dummies Questions & Answers

file was created before 15 days ago.

How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago? It has to be korn shell script. Thanks. (1 Reply)
Discussion started by: YoungBlood
1 Replies

4. Shell Programming and Scripting

Find the file from 15 days ago

How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago? It has to be korn shell script. Thanks. (2 Replies)
Discussion started by: YoungBlood
2 Replies

5. Shell Programming and Scripting

date for two days or 3 days ago

i need a script that can tell me the date 2 days ago or 3 days ago. please help (7 Replies)
Discussion started by: tomjones
7 Replies

6. Shell Programming and Scripting

Date within a timeframe 2 days ago

How could I using the following example, change it to show 2 days ago within the same time frame 0600 AM to 0600 AM let foo=`date "+(1%H-106)*60+1%M-100"` bar=foo+1440 find . -mmin +$foo -mmin -$bar | tr -s '/','-' '^' | cut -f2,3 -d"^" | tr -s '^' ' ' | Please use code tags (7 Replies)
Discussion started by: freddie999
7 Replies

7. Shell Programming and Scripting

Find unix file created how many days ago?

i want to find unix file created how many days ago? (4 Replies)
Discussion started by: utoptas
4 Replies

8. UNIX for Advanced & Expert Users

N days ago

Hi, the following gives today $(date '+%d%m%y') For example 210111 for today (21 of january 2011). How can I have n days ego ? For example 160111 for 5 days ego ? thank you. (3 Replies)
Discussion started by: big123456
3 Replies

9. Shell Programming and Scripting

Find a string in file 5 days ago

Hi, I need to grep for a string "Color Yellow" in all log files dated 5 days back until today's date . So, as today is 20 Dec i need to find in all logs from 16th dec to 20 dec. Also, i need ls -ltre output for the files that have the "Collor Yellow" string. Below is my OS: ... (1 Reply)
Discussion started by: mohtashims
1 Replies

10. Shell Programming and Scripting

Get a given date and subtract it to 5 days ago

Hi all, I have been researching to obtain SSL certification expiry for most of our webistes. For some cases, some hosts where not directly accessible so i finally got a solution working with curl using my proxy. This lists the expiry date which i'm finally looking for. # curl --proxy... (4 Replies)
Discussion started by: nms
4 Replies
E2TOOLS(7)						 Miscellaneous Information Manual						E2TOOLS(7)

NAME
e2tools - utilities to manipulate files in an ext2/ext3 filesystem DESCRIPTION
E2tools is a simple set of GPL'ed utilities to read, write, and manipulate files in an ext2/ext3 filesystem. These utilities access a filesystem directly using the ext2fs library. I wrote these tools in order to copy files into a linux filesystem on a machine that does not have ext2 support. Of course, they can also be used on a linux machine to read/write to disk images or floppies without having to mount them or have root access. Supported functionality: e2cp copy files e2mv move files e2rm remove files e2mkdir create directory e2ln create hard links e2ls list files/directories e2tail output the last part of a file In general, to specify a directory or file on an ext2 filesystem for the e2tools utilities, use the following form: filesystem:directory_path The filesystem can be an unmounted partition or a regular file that's been formatted to contain an ext2 filesystem. In general, if a com- mand takes multiple file names on the command line, if the first one contains an ext2 file specification, the rest of the files are assumed to be on the same filesystem until another one is explicitly stated: /tmp/boot.img:/tmp/file1 /tmp/file2 /tmp/file3 /tmp/boot2.img:/tmp/file4 Files 1-3 are on /tmp/boot.img and the last file is on /tmp/boot2.img SEE ALSO
e2cp(1), e2ln(1), e2ls(1), e2mkdir(1), e2mv(1), e2rm(1), e2tail(1). AUTHOR
The e2tools were written by Keith Sheffield <sheff@pobox.com>. This manual page was written by Lucas Wall <lwall@debian.org>, for the Debian project (but may be used by others). March 2, 2005 E2TOOLS(7)
All times are GMT -4. The time now is 03:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy