Reverse detail from Kakelbont MS 1, a fifteenth-century French Psalter. This image is in the public domain. Daniel Paul O'Donnell

Forward to Navigation

Finding files modified within a specific time period

Posted: Apr 21, 2018 14:04;
Last Modified: Apr 21, 2018 14:04
Keywords:

---

I had been working experimentally on a file a couple of days ago and forgot to change the name to something meaningful. I remembered roughly when I was working on it and would recognise the name and context when I saw it (probably). But the problem is how to you find the relevant files? Stackoverflow to the rescue (as always), with a bit of man find:

find /home/dan/ -name *.xml -mtime -2 -ls |more

It’s all pretty self explanatory except the -mtime -2: the utility, the start directory, any restrictions on the file name (you want to use this if you are searching a home directory: I have 10k+ files, it looked like before I added it, given all the cache files from the web browsers), the time period in days (-mtime), and a ls-style display. |more is a pipe that allows you to look at the output in segments if there is more than a screen’s worth.

-mtime is the only funny bit: it searches back the number of days expressed by its value. If the value is positive, it searches back roughly that number of days from the moment it is invoked (roughly in the sense of “about 48 hours ago” in this case); if the number is negative, it search back from now until that number of days (or in this case “from now back to about two days ago”).

If you need a timeframe less than a day, there is a switch for minutes as well.

----  

Comment

:
:

:

Textile help

Back to content

Search my site

Sections

Current teaching

Recent changes to this site

Tags

anglo-saxon studies, caedmon, citation practice, composition, computers, digital humanities, digital pedagogy, grammar, history, moodle, old english, pedagogy, research, students, study tips, teaching, tips, tutorials, unessay, universities

See all...

Follow me on Twitter